Skip to content

Commit 7bdc4eb

Browse files
authored
chore: fix code formatting
1 parent ac71382 commit 7bdc4eb

File tree

1 file changed

+65
-62
lines changed

1 file changed

+65
-62
lines changed

views/realtime_guide-android.md

Lines changed: 65 additions & 62 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
{% block demo %}
1212
* [LeanMessage](https://github.com/leancloud/LeanMessage-Demo)(推荐)
1313
* [LeanChat](https://github.com/leancloud/leanchat-android)
14-
{% endblock %}
14+
{% endblock %}
1515

1616
{% block oneOnOneChat_sent %}
1717
{{ docs.alert("启用实时通信一定要正确配置 `AndroidManifest.xml`,请仔细阅读 [Android SDK 初始化配置](sdk_setup-android.html#初始化)。") }}
@@ -161,89 +161,92 @@ public void jerryReceiveMsgFromTom(){
161161

162162
{% block groupChat_received %}
163163
```
164-
public class MyApplication extends Application{
165-
public void onCreate(){
166-
...
167-
AVOSCloud.initialize(this,"{{appid}}","{{appkey}}");
168-
//这里指定只处理AVIMTextMessage类型的消息
169-
AVIMMessageManager.registerMessageHandler(AVIMTextMessage.class,new CustomMessageHanlder());
164+
public class MyApplication extends Application {
165+
public void onCreate() {
166+
...
167+
AVOSCloud.initialize(this, "{{appid}}", "{{appkey}}");
168+
//这里指定只处理AVIMTextMessage类型的消息
169+
AVIMMessageManager.registerMessageHandler(AVIMTextMessage.class, new CustomMessageHanlder());
170170
}
171171
}
172172
173-
- CustomMessageHandler.java
174-
public class CustomMessageHandler<AVIMTextMessage> implements AVIMTypedMessageHandler{
175-
173+
// =========================
174+
// CustomMessageHandler.java
175+
// =========================
176+
public class CustomMessageHandler < AVIMTextMessage > implements AVIMTypedMessageHandler {
177+
176178
@Override
177-
public void onMessage(AVIMTextMessage msg,AVIMConversation conv,AVIMClient client){
178-
Log.d("Tom & Jerry",msg.getText();)//你们在哪儿?
179+
public void onMessage(AVIMTextMessage msg, AVIMConversation conv, AVIMClient client) {
180+
Log.d("Tom & Jerry", msg.getText();) //你们在哪儿?
179181
// 收到消息之后一般的做法是做 UI 展现,示例代码在此处做消息回复,仅为了演示收到消息之后的操作,仅供参考。
180182
AVIMTextMessage reply = new AVIMTextMessage();
181183
reply.setText("Tom,我在 Jerry 家,你跟 Harry 什么时候过来?还有 William 和你在一起么?");
182-
conv.sendMessage(reply,new AVIMConversationCallback(){
183-
public void done(AVIMException e){
184-
if(e==null){
185-
//回复成功!
186-
}
187-
}
188-
});
184+
conv.sendMessage(reply, new AVIMConversationCallback() {
185+
public void done(AVIMException e) {
186+
if (e == null) {
187+
//回复成功!
188+
}
189+
}
190+
});
189191
}
190-
191-
public void onMessageReceipt(AVIMTextMessage msg,AVIMConversation conv,AVIMClient client){
192-
193-
}
194-
}
195192
193+
public void onMessageReceipt(AVIMTextMessage msg, AVIMConversation conv, AVIMClient client) {
196194
197-
- SomeActivity.java
198-
public void loginAsBob(){
199-
AVIMClient bob = AVIMClient.getInstance("Bob");
200-
//Bob登录
201-
bob.open(new AVIMClientCallback(){
202-
public void done(AVIMClient client,AVIMException e){
203-
if(e==null){
204-
//登录成功
205-
}
206-
}
207-
});
195+
}
196+
}
197+
198+
// =================
199+
// SomeActivity.java
200+
// =================
201+
public void loginAsBob() {
202+
AVIMClient bob = AVIMClient.getInstance("Bob");
203+
//Bob登录
204+
bob.open(new AVIMClientCallback() {
205+
public void done(AVIMClient client, AVIMException e) {
206+
if (e == null) {
207+
//登录成功
208+
}
209+
}
210+
});
208211
}
209212
```
210213
{% endblock %}
211214

212215
{% block imageMessage_local_sent %}
213216

214217
```
215-
public void sendImage(String filePath){
218+
public void sendImage(String filePath) {
216219
AVIMClient tom = AVIMClient.getInstance("Tom");
217220
218-
tom.open(new AVIMClientCallback(){
219-
221+
tom.open(new AVIMClientCallback() {
222+
220223
@Override
221-
public void done(AVIMClient client,AVIMException e){
222-
if(e==null){
223-
//登录成功
224-
// 创建对话,默认创建者是在包含在成员列表中的
225-
client.createConversation(Arrays.asList("Jerry"),new AVIMConversationCreatedCallback(){
226-
227-
@Override
228-
public void done(AVIMConversation conv,AVIMException e){
229-
if(e==null){
230-
AVIMImageMessage picture = new AVIMImageMessage(filePath);
231-
picture.setText("发自我的小米");
232-
Map<String,Object> attributes = new HashMap<String,Object>();
233-
attributes.put("location","旧金山");
234-
picture.setAttribute(attributes);
235-
conv.sendMessage(picture,new AVIMConversationCallback(){
236-
237-
@Override
238-
public void done(AVIMException e){
239-
if(e==null){
240-
//发送成功!
224+
public void done(AVIMClient client, AVIMException e) {
225+
if (e == null) {
226+
//登录成功
227+
// 创建对话,默认创建者是在包含在成员列表中的
228+
client.createConversation(Arrays.asList("Jerry"), new AVIMConversationCreatedCallback() {
229+
230+
@Override
231+
public void done(AVIMConversation conv, AVIMException e) {
232+
if (e == null) {
233+
AVIMImageMessage picture = new AVIMImageMessage(filePath);
234+
picture.setText("发自我的小米");
235+
Map < String, Object > attributes = new HashMap < String, Object > ();
236+
attributes.put("location", "旧金山");
237+
picture.setAttribute(attributes);
238+
conv.sendMessage(picture, new AVIMConversationCallback() {
239+
240+
@Override
241+
public void done(AVIMException e) {
242+
if (e == null) {
243+
//发送成功!
244+
}
241245
}
242-
}
243-
});
246+
});
247+
}
244248
}
245-
}
246-
});
249+
});
247250
}
248251
}
249252
});

0 commit comments

Comments
 (0)