Skip to content

Commit

Permalink
Update Android doc.
Browse files Browse the repository at this point in the history
  • Loading branch information
lhw5123 committed May 11, 2017
1 parent 6b8b86f commit 2d2e414
Show file tree
Hide file tree
Showing 8 changed files with 111 additions and 88 deletions.
21 changes: 9 additions & 12 deletions Android/chatinput/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
提供了以下几种方式添加依赖,只需要选择其中一种即可。

- Gradle
```
```groovy
compile 'cn.jiguang.imui:chatinput:0.1.1'
```

Expand All @@ -27,7 +27,7 @@ compile 'cn.jiguang.imui:chatinput:0.1.1'
- JitPack
> project 下的 build.gradle
```
```groovy
allprojects {
repositories {
...
Expand All @@ -39,7 +39,7 @@ allprojects {

> module 的 build.gradle
```
```groovy
dependencies {
compile 'com.github.jpush:imui:0.1.1'
}
Expand All @@ -50,7 +50,7 @@ dependencies {

#### 在 xml 布局文件中引用 ChatInputView:

```
```xml
<cn.jiguang.imui.chatinput.ChatInputView
android:id="@+id/chat_input"
android:layout_width="match_parent"
Expand All @@ -63,12 +63,11 @@ dependencies {
app:photoBtnIcon="@drawable/photo"
app:sendBtnIcon="@drawable/send"
app:voiceBtnIcon="@drawable/mic" />
```

#### 初始化 ChatInputView

```
```java
ChatInputView chatInputView = (ChatInputView) findViewById(R.id.chat_input);
chatInputView.setMenuContainerHeight(softInputHeight);
```
Expand All @@ -82,7 +81,7 @@ ChatInputView 提供了各种按钮及事件的监听回调,所以用户可以

#### OnMenuClickListener
首先是输入框下面的菜单栏事件的监听,调用 chatInputView.setMenuClickListener 即可设置监听:
```
```java
chatInput.setMenuClickListener(new OnMenuClickListener() {
@Override
public boolean onSendTextMessage(CharSequence input) {
Expand Down Expand Up @@ -115,7 +114,7 @@ chatInput.setMenuClickListener(new OnMenuClickListener() {
#### RecordVoiceListener
这是录音的接口,使用方式:

```
```java
mRecordVoiceBtn = mChatInput.getRecordVoiceButton();
mRecordVoiceBtn.setRecordVoiceListener(new RecordVoiceListener() {
@Override
Expand Down Expand Up @@ -146,7 +145,7 @@ mRecordVoiceBtn.setRecordVoiceListener(new RecordVoiceListener() {

#### OnCameraCallbackListener
这是相机相关的接口,使用方式:
```
```java
mChatInput.setOnCameraCallbackListener(new OnCameraCallbackListener() {
@Override
public void onTakePictureCompleted(String photoPath) {
Expand Down Expand Up @@ -179,12 +178,10 @@ mChatInput.setOnCameraCallbackListener(new OnCameraCallbackListener() {
});
```


#### 设置拍照后保存的文件
setCameraCaptureFile(String path, String fileName)

```
```java
// 参数分别是路径及文件名,建议在上面的 onCameraClick 触发时调用
mChatInput.setCameraCaptureFile(path, fileName);
```
23 changes: 10 additions & 13 deletions Android/chatinput/README_EN.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ features like record voice and video, select photo, take picture etc, supports c
Provides several ways to add dependency, you can choose one of them:

- Via Gradle
```
```groovy
compile 'cn.jiguang.imui:chatinput:0.1.1'
```

Expand All @@ -28,19 +28,18 @@ compile 'cn.jiguang.imui:chatinput:0.1.1'
- Via JitPack
> project's build.gradle
```
```groov
allprojects {
repositories {
...
maven { url 'https://jitpack.io' }
}
}
```

> module's build.gradle
```
```groovy
dependencies {
compile 'com.github.jpush:imui:0.1.1'
}
Expand All @@ -51,7 +50,7 @@ Using ChatInputView only need two steps.

#### Step one: add `ChatInputView` in xml layout

```
```xml
<cn.jiguang.imui.chatinput.ChatInputView
android:id="@+id/chat_input"
android:layout_width="match_parent"
Expand All @@ -64,19 +63,18 @@ Using ChatInputView only need two steps.
app:photoBtnIcon="@drawable/photo"
app:sendBtnIcon="@drawable/send"
app:voiceBtnIcon="@drawable/mic" />
```

#### Step two: init `ChatInputView`

```
```java
ChatInputView chatInputView = (ChatInputView) findViewById(R.id.chat_input);
chatInputView.setMenuContainerHeight(softInputHeight);
```

Attention please, **MUST** set MenuContainer's height after init ChatInputView. Best suggestion: get
soft keyboard height from other activity(Like login Activity), then set soft keyboard height via:
```
```java
ChatInputView chatinput = (ChatInputView) findViewById(R.id.chat_input);
chatinput.setMenuContainerHeight(softKeyboardHeight);
```
Expand All @@ -93,7 +91,7 @@ event listener to do their stuff flexibly. Such as send message event etc.
#### OnMenuClickListener
First of all, `OnMenuClickListener` handling click event of menu item. Call `chatInputView.setMenuClickListener`
can set this listener:
```
```java
chatInput.setMenuClickListener(new OnMenuClickListener() {
@Override
public boolean onSendTextMessage(CharSequence input) {
Expand Down Expand Up @@ -128,7 +126,7 @@ As for how to handle these events and what to do with these events, you can refe
#### RecordVoiceListener
This is the interface of record voice, the way to use:

```
```java
mRecordVoiceBtn = mChatInput.getRecordVoiceButton();
mRecordVoiceBtn.setRecordVoiceListener(new RecordVoiceListener() {
@Override
Expand Down Expand Up @@ -159,7 +157,7 @@ mRecordVoiceBtn.setRecordVoiceListener(new RecordVoiceListener() {

#### OnCameraCallbackListener
This is interface related to camera, usage like:
```
```java
mChatInput.setOnCameraCallbackListener(new OnCameraCallbackListener() {
@Override
public void onTakePictureCompleted(String photoPath) {
Expand Down Expand Up @@ -197,9 +195,8 @@ mChatInput.setOnCameraCallbackListener(new OnCameraCallbackListener() {
#### Set file path and file name that after taken picture
setCameraCaptureFile(String path, String fileName)

```
```java
// The first parameter is file path that saved at, second one is file name
// Suggest calling this method when onCameraClick fires
mChatInput.setCameraCaptureFile(path, fileName);
```
17 changes: 8 additions & 9 deletions docs/Android/customLayout.md
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
## 自定义界面样式
# 自定义界面样式

[English Docment](./customLayoutEn.md)

如果你需要对界面样式做更多定制化的需求,例如消息状态,设置已读标签等等,你可以使用自定义 ViewHolder 及布局。

### 用法
自定义界面的样式只需要三个步骤
## 用法
自定义界面的样式只需要三个步骤

#### 创建自定义布局界面
### 1. 创建自定义布局界面
在 layout 中创建你自己的布局文件。

#### 构建 ViewHolder 继承自 BaseMessageViewHolder 并实现 DefaultMessageViewHolder
### 2. 构建 ViewHolder 继承自 BaseMessageViewHolder 并实现 DefaultMessageViewHolder
自定义的 ViewHolder 类构造函数的两个参数类型必须为 View 以及 boolean。可以参考一下 messages 文件夹下的 ViewHolder 类。 例如:

```
```java
public class TxtViewHolder<MESSAGE extends IMessage>
extends BaseMessageViewHolder<MESSAGE>
implements MsgListAdapter.DefaultMessageViewHolder {
Expand All @@ -23,7 +23,6 @@ public class TxtViewHolder<MESSAGE extends IMessage>
...
}

@Override
public void onBind(final MESSAGE message) {
...
Expand All @@ -35,9 +34,9 @@ public class TxtViewHolder<MESSAGE extends IMessage>
}
```

#### 使用 HoldersConfig 对象设置 ViewHolder 及布局
### 3. 使用 HoldersConfig 对象设置 ViewHolder 及布局

```
```java
MsgListAdapter.HoldersConfig holdersConfig = new MsgListAdapter.HoldersConfig();
// 第一个参数是自定义的 ViewHolder 类,第二个是自定义布局文件的资源 id
holdersConfig.setSenderTxtMsg(CustomViewHolder.class, layoutRes);
Expand Down
14 changes: 7 additions & 7 deletions docs/Android/customLayoutEn.md
Original file line number Diff line number Diff line change
@@ -1,21 +1,21 @@
## Customize widget style
# Customize widget style
[中文文档](./customLayout.md)

If you want to totally customize your widget, you can define custom ViewHolder and layout.
This document will show you how to do it.

### Step
## Step
Customize your widget style only need three steps.

#### Step one: create custom message item layout
### Step one: create custom message item layout
Create xml layout file, you can refer MessageList's message item layout.


#### Step two:Create ViewHolder extends BaseMessageViewHolder and implements DefaultMessageViewHolder
### Step two:Create ViewHolder extends BaseMessageViewHolder and implements DefaultMessageViewHolder
The custom ViewHolder's constructor **must** have two types of parameter: View type and boolean type. For example:


```
```java
public class TxtViewHolder<MESSAGE extends IMessage>
extends BaseMessageViewHolder<MESSAGE>
implements MsgListAdapter.DefaultMessageViewHolder {
Expand All @@ -38,11 +38,11 @@ public class TxtViewHolder<MESSAGE extends IMessage>
}
```

#### Step three: Use HoldersConfig object to set custom ViewHolder and layout
### Step three: Use HoldersConfig object to set custom ViewHolder and layout
Remember there several kinds of message: text, photo, voice, video, so you need in place all of them,
otherwise, will use default style.

```
```java
MsgListAdapter.HoldersConfig holdersConfig = new MsgListAdapter.HoldersConfig();
// First parameter is custom ViewHolder class,second one is resource id of custom layout.
holdersConfig.setSenderTxtMsg(CustomViewHolder.class, layoutRes);
Expand Down
45 changes: 31 additions & 14 deletions docs/Android/imageLoader.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,25 +4,42 @@
为了不限定加载图片的方式(有很多第三方库可以很方便地用来加载图片),我们提供了 ImageLoader 接口,只要实现这个接口,就可以
使用你自己定义的方式来加载图片。
例如使用 Picasso 来加载图片:
```
```java
ImageLoader imageLoader = new ImageLoader() {
@Override
public void loadImage(ImageView imageView, String url) {
Picasso.with(MessagesListActivity.this).load(url).into(imageView);
}
@Override
public void loadAvatarImage(ImageView avatarImageView, String string) {
Glide.with(mContext)
.load(string)
.centerCrop()
.into(avatarImageView);
}

@Override
public void loadImage(ImageView imageView, String string) {
Picasso.with(mContext)
.load(string)
.into(imageView);
}
};
```

或者 Glide:

```
```java
ImageLoader imageLoader = new ImageLoader() {
@Override
public void loadImage(ImageView imageView, String url) {
Glide.with(mContext)
.load(url)
.centerCrop()
.into(imageView);
}
@Override
public void loadAvatarImage(ImageView avatarImageView, String string) {
Glide.with(mContext)
.load(string)
.centerCrop()
.into(avatarImageView);
}

@Override
public void loadImage(ImageView imageView, String string) {
Glide.with(mContext)
.load(string)
.centerCrop()
.into(imageView);
}
};
```
48 changes: 32 additions & 16 deletions docs/Android/imageLoaderEn.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,26 +5,42 @@ For loading images with free style(There are many third-party libraries can easi
we define ImageLoader interface, so you can use the way you like to load image.

Take Picasso for example:

```
```java
ImageLoader imageLoader = new ImageLoader() {
@Override
public void loadImage(ImageView imageView, String url) {
Picasso.with(MessagesListActivity.this).load(url).into(imageView);
}
@Override
public void loadAvatarImage(ImageView avatarImageView, String string) {
Glide.with(mContext)
.load(string)
.centerCrop()
.into(avatarImageView);
}

@Override
public void loadImage(ImageView imageView, String string) {
Picasso.with(mContext)
.load(string)
.into(imageView);
}
};
```

or Glide:

```
```java
ImageLoader imageLoader = new ImageLoader() {
@Override
public void loadImage(ImageView imageView, String url) {
Glide.with(mContext)
.load(url)
.centerCrop()
.into(imageView);
}
@Override
public void loadAvatarImage(ImageView avatarImageView, String string) {
Glide.with(mContext)
.load(string)
.centerCrop()
.into(avatarImageView);
}

@Override
public void loadImage(ImageView imageView, String string) {
Glide.with(mContext)
.load(string)
.centerCrop()
.into(imageView);
}
};
```
```
Loading

0 comments on commit 2d2e414

Please sign in to comment.