Sfoglia il codice sorgente

优化IM部分流程

Pq 1 mese fa
parent
commit
523335e7ee

+ 5 - 0
chatModule/src/main/java/com/cooleshow/chatmodule/message/bean/TUIChatGroupNoticeMessageBean.java

@@ -71,6 +71,11 @@ public class TUIChatGroupNoticeMessageBean extends TUIMessageBean {
     }
 
     @Override
+    public String getExtra() {
+        return "[群公告]";
+    }
+
+    @Override
     public void onProcessMessage(V2TIMMessage v2TIMMessage) {
         String data = new String(v2TIMMessage.getCustomElem().getData());
         try {

+ 5 - 0
chatModule/src/main/java/com/cooleshow/chatmodule/message/bean/TUIChatShareLiveMessageBean.java

@@ -64,6 +64,11 @@ public class TUIChatShareLiveMessageBean extends TUIMessageBean {
     }
 
     @Override
+    public String getExtra() {
+        return "[直播分享]";
+    }
+
+    @Override
     public void onProcessMessage(V2TIMMessage v2TIMMessage) {
         String data = new String(v2TIMMessage.getCustomElem().getData());
         try {

+ 5 - 0
chatModule/src/main/java/com/cooleshow/chatmodule/message/bean/TUIChatShareMusicMessageBean.java

@@ -88,6 +88,11 @@ public class TUIChatShareMusicMessageBean extends TUIMessageBean {
     }
 
     @Override
+    public String getExtra() {
+        return "[曲谱分享]";
+    }
+
+    @Override
     public void onProcessMessage(V2TIMMessage v2TIMMessage) {
         String data = new String(v2TIMMessage.getCustomElem().getData());
         try {

+ 4 - 0
chatModule/src/main/java/com/cooleshow/chatmodule/ui/TUIC2CChatActivityV2.java

@@ -12,6 +12,7 @@ import com.cooleshow.chatmodule.api.IMApi;
 import com.cooleshow.chatmodule.bean.IMGroupInfo;
 import com.cooleshow.chatmodule.bean.IMUserInfo;
 import com.cooleshow.chatmodule.manager.IMCenter;
+import com.cooleshow.chatmodule.utils.helper.ChatHelper;
 import com.tencent.qcloud.tuicore.TUIConstants;
 import com.tencent.qcloud.tuikit.timcommon.component.interfaces.IUIKitCallback;
 import com.tencent.qcloud.tuikit.tuichat.bean.ChatInfo;
@@ -37,6 +38,9 @@ public class TUIC2CChatActivityV2 extends TUIC2CChatActivity {
         super.initChat(chatInfo);
         LOG.i("TUIC2CChatActivityV2","id:"+chatInfo.getId());
         conversationId = getIntent().getStringExtra(TUIConstants.TUIChat.CONVERSATION_ID);
+        if(TextUtils.isEmpty(conversationId)){
+            conversationId = ChatHelper.getInstance().getConversionId(chatInfo);
+        }
         if(chatInfo!=null && !TextUtils.isEmpty(chatInfo.getId())){
             checkUserStatus(chatInfo.getId());
         }

+ 4 - 0
chatModule/src/main/java/com/cooleshow/chatmodule/ui/TUIChatGroupActivityV2.java

@@ -15,6 +15,7 @@ import com.cooleshow.chatmodule.R;
 import com.cooleshow.chatmodule.api.IMApi;
 import com.cooleshow.chatmodule.bean.IMGroupInfo;
 import com.cooleshow.chatmodule.manager.IMCenter;
+import com.cooleshow.chatmodule.utils.helper.ChatHelper;
 import com.cooleshow.usercenter.helper.UserHelper;
 import com.tencent.imsdk.v2.V2TIMGroupChangeInfo;
 import com.tencent.imsdk.v2.V2TIMGroupMemberChangeInfo;
@@ -69,6 +70,9 @@ public class TUIChatGroupActivityV2 extends TUIGroupChatActivity {
     public void initChat(ChatInfo chatInfo) {
         super.initChat(chatInfo);
         conversationId = getIntent().getStringExtra(TUIConstants.TUIChat.CONVERSATION_ID);
+        if(TextUtils.isEmpty(conversationId)){
+            conversationId = ChatHelper.getInstance().getConversionId(chatInfo);
+        }
         GroupInfo groupInfo = (GroupInfo) chatInfo;
         groupId = groupInfo.getId();
         currentImUserId = UserHelper.getImUserId();

+ 9 - 0
chatModule/src/main/java/com/cooleshow/chatmodule/utils/helper/ChatHelper.java

@@ -18,6 +18,7 @@ import com.tencent.imsdk.v2.V2TIMSendCallback;
 import com.tencent.qcloud.tuicore.TUIConstants;
 import com.tencent.qcloud.tuicore.TUICore;
 import com.tencent.qcloud.tuikit.timcommon.bean.TUIMessageBean;
+import com.tencent.qcloud.tuikit.tuichat.bean.ChatInfo;
 import com.tencent.qcloud.tuikit.tuichat.util.ChatMessageBuilder;
 
 /**
@@ -169,4 +170,12 @@ public class ChatHelper {
     private static class ChatHelperHolder {
         public static ChatHelper mHelper = new ChatHelper();
     }
+
+    public String getConversionId(ChatInfo chatInfo) {
+        if (ChatInfo.TYPE_GROUP == chatInfo.getType()) {
+            return TUIConstants.TUIConversation.CONVERSATION_GROUP_PREFIX + chatInfo.getId();
+        } else {
+            return TUIConstants.TUIConversation.CONVERSATION_C2C_PREFIX + chatInfo.getId();
+        }
+    }
 }