Skip to content

Commit

Permalink
消息透传协议
Browse files Browse the repository at this point in the history
  • Loading branch information
chenyanan committed Dec 29, 2017
1 parent 740d1b1 commit 0e82a6b
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 4 deletions.
27 changes: 23 additions & 4 deletions chatapp/src/main/java/jiguang/chat/activity/ChatActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,9 @@

import com.sj.emoji.EmojiBean;

import org.json.JSONException;
import org.json.JSONObject;

import java.io.File;
import java.lang.ref.WeakReference;
import java.util.ArrayList;
Expand Down Expand Up @@ -375,9 +378,9 @@ public void onTextChanged(CharSequence s, int start, int count, int after) {
ekBar.getEtChat().setOnFocusChangeListener((v, hasFocus) -> {
String content;
if (hasFocus) {
content = "对方正在输入...";
content = "{\"type\": \"input\",\"content\": {\"message\": \"对方正在输入\"}}";
} else {
content = mConv.getTitle();
content = "{\"type\": \"input\",\"content\": {\"message\": \"\"}}";
}
if (mIsSingle) {
JMessageClient.sendSingleTransCommand(mTargetId, null, content, new BasicCallback() {
Expand Down Expand Up @@ -421,7 +424,7 @@ private void initEmoticonsKeyBoardBar() {
} else if (null != mAtList) {
msg = mConv.createSendMessage(content, mAtList, null);
} else {
LogUtils.d("ChatActivity", "create send message conversation = " + mConv +"==content==" + content.toString());
LogUtils.d("ChatActivity", "create send message conversation = " + mConv + "==content==" + content.toString());
msg = mConv.createSendMessage(content);
}

Expand Down Expand Up @@ -681,7 +684,23 @@ protected void onResume() {
public void onEvent(CommandNotificationEvent event) {
if (event.getType().equals(CommandNotificationEvent.Type.single)) {
String msg = event.getMsg();
runOnUiThread(() -> mChatView.setTitle(msg));
runOnUiThread(new Runnable() {
@Override
public void run() {
try {
JSONObject object = new JSONObject(msg);
JSONObject jsonContent = object.getJSONObject("content");
String messageString = jsonContent.getString("message");
if (TextUtils.isEmpty(messageString)) {
mChatView.setTitle(mConv.getTitle());
} else {
mChatView.setTitle(messageString);
}
} catch (JSONException e) {
e.printStackTrace();
}
}
});
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ public ChatRoomController(ChatRoomView chatRoomView, Context context) {
private void initChatRoomAdapter() {
Dialog loadingDialog = DialogCreator.createLoadingDialog(mContext, "正在加载...");
loadingDialog.show();
//这里获取的聊天室数量应该有设计设计怎么获取的逻辑???
ChatRoomManager.getChatRoomListByApp(0, 10, new RequestCallback<List<ChatRoomInfo>>() {
@Override
public void gotResult(int i, String s, List<ChatRoomInfo> chatRoomInfos) {
Expand Down

0 comments on commit 0e82a6b

Please sign in to comment.