Browse Source

fix: message info

tongmengxiao 2 tháng trước cách đây
mục cha
commit
6eede5dd19

+ 0 - 3
baseswago/src/main/java/com/swago/baseswago/PersonDataDFragment.kt

@@ -43,7 +43,6 @@ class PersonDataDFragment : BaseXDFragment<DialogPersonDataBinding>() {
     var nickIcon = ""
     var account = ""
     var roomId:String = ""
-    var chatSpecial:String = ""
     var headSpecial:String = ""
     var isAnchor = false //是否是主播点击了资料卡
     var isAdmin = false
@@ -130,7 +129,6 @@ class PersonDataDFragment : BaseXDFragment<DialogPersonDataBinding>() {
                                     ARouter.getInstance().build(ARouteConstant.Home.chatDetail)
                                         .withString("account",account)
                                         .withString("chatName",binding.tvName.text.toString())
-                                        .withString("chatSpecial" , chatSpecial)
                                         .withString("headSpecial" , headSpecial).navigation()
                                     dismissAllowingStateLoss()
                                 } else {
@@ -179,7 +177,6 @@ class PersonDataDFragment : BaseXDFragment<DialogPersonDataBinding>() {
             nickName = it.user_name
             nickIcon = it.user_head_img_url
             account = it.user_account
-            chatSpecial = it.android_chat_special
             headSpecial = it.android_head_special
             binding.ivVip.visibility = if (it.is_benefit==1) View.VISIBLE else View.GONE
             Glide.with(this).load(it.user_head_img_url)

+ 12 - 14
home/src/main/java/com/swago/home/ChatDetailActivity.kt

@@ -47,6 +47,10 @@ class ChatDetailActivity  : BaseXActivity<ActivityChatDetailBinding>() {
     @JvmField
     var chatName: String = ""
 
+    @Autowired(required = true)
+    @JvmField
+    var headSpecial: String = ""
+
     private var svgaParser:SVGAParser? = null
 
     private var messageRecyclerView:MessageLayout?=null
@@ -67,9 +71,6 @@ class ChatDetailActivity  : BaseXActivity<ActivityChatDetailBinding>() {
         ARouter.getInstance().inject(this)
 
         svgaParser = SVGAParser(this)
-        if (!TextUtils.isEmpty(account)){
-            userVm.getOtherUserInfo(account,"")
-        }
         val chatInfo = ChatInfo()
         chatInfo.type = V2TIMConversation.V2TIM_C2C
         chatInfo.chatName = chatName
@@ -132,20 +133,17 @@ class ChatDetailActivity  : BaseXActivity<ActivityChatDetailBinding>() {
                 }
             }
         }
+        if (!TextUtils.isEmpty(headSpecial)){
+            svgaParser?.decodeFromURL(URL(headSpecial), object :SVGAParser.ParseCompletion{
+                override fun onComplete(videoItem: SVGAVideoEntity) {
+                    messageRecyclerView?.leftSvgaAvatar = videoItem
+                }
 
-        userVm.otherUserInfoLiveData.observe(this){
-            if (!TextUtils.isEmpty(it.android_head_special)){
-                svgaParser?.decodeFromURL(URL(it.android_head_special), object :SVGAParser.ParseCompletion{
-                    override fun onComplete(videoItem: SVGAVideoEntity) {
-                        messageRecyclerView?.leftSvgaAvatar = videoItem
-                    }
-
-                    override fun onError() {
+                override fun onError() {
 
-                    }
-                })
+                }
+            })
 
-            }
         }
 
         if (UserInfo.getUserInfo() != null && !TextUtils.isEmpty(UserInfo.getUserInfo()?.android_head_special)){

+ 22 - 5
home/src/main/java/com/swago/home/MessageFragment.kt

@@ -28,7 +28,10 @@ import com.tencent.qcloud.tim.uikit.modules.conversation.base.ConversationInfo
  *description:
  */
 class MessageFragment : BaseXFragment<FragmentMessageBinding>() {
+    private val userVm by viewModels<UserVm>()
     private val officialVm by activityViewModels<OfficialVm>()
+    private var conversationInfo: ConversationInfo ?= null
+    private var jumpDetail = true
 
     override fun loadData() {
         officialVm.getMsgSum()
@@ -41,11 +44,8 @@ class MessageFragment : BaseXFragment<FragmentMessageBinding>() {
                 .permissions(Manifest.permission.RECORD_AUDIO,Manifest.permission.CAMERA)
                 .request { allGranted, grantedList, deniedList ->
                     if (allGranted) {
-                        ARouter.getInstance().build(ARouteConstant.Home.chatDetail)
-                            .withInt("type", V2TIMConversation.V2TIM_C2C)
-                            .withString("account", messageInfo?.id)
-                            .withString("chatName", messageInfo?.title)
-                            .navigation()
+                        conversationInfo = messageInfo
+                        userVm.getOtherUserInfo(messageInfo.id,"")
                     } else {
                         Toast.makeText(
                             AppContext.getContext(),
@@ -91,5 +91,22 @@ class MessageFragment : BaseXFragment<FragmentMessageBinding>() {
                 binding.tvCount.visibility = View.VISIBLE
             }
         }
+        userVm.otherUserInfoLiveData.observe(this){
+            if (jumpDetail){
+                ARouter.getInstance().build(ARouteConstant.Home.chatDetail)
+                    .withInt("type", V2TIMConversation.V2TIM_C2C)
+                    .withString("account", conversationInfo?.id)
+                    .withString("chatName", conversationInfo?.title)
+                    .withString("headSpecial" , it.android_head_special)
+                    .navigation()
+            }
+            jumpDetail = false
+
+        }
+    }
+
+    override fun onResume() {
+        super.onResume()
+        jumpDetail = true
     }
 }

+ 16 - 8
room/src/main/java/com/swago/room/dialog/MessageListDialog.kt

@@ -23,6 +23,7 @@ import com.tencent.qcloud.tim.uikit.modules.conversation.base.ConversationInfo
 class MessageListDialog : BaseXDFragment<DialogMessageListBinding>() {
     private val userVm by viewModels<UserVm>()
     private var conversationInfo: ConversationInfo?= null
+    private var jumpDetail = true
 
     init {
         setDimAmount(0f)
@@ -51,14 +52,16 @@ class MessageListDialog : BaseXDFragment<DialogMessageListBinding>() {
 
             }
 
-            userVm.otherUserInfoLiveData.observe(it){
-                ARouter.getInstance().build(ARouteConstant.Home.chatDetail)
-                    .withInt("type", V2TIMConversation.V2TIM_C2C)
-                    .withString("account", conversationInfo?.id)
-                    .withString("chatName", conversationInfo?.title)
-                    .withString("chatSpecial" , it.android_chat_special)
-                    .withString("headSpecial" , it.android_head_special)
-                    .navigation()
+            userVm.otherUserInfoLiveData.observe(it){model ->
+                if (jumpDetail){
+                    ARouter.getInstance().build(ARouteConstant.Home.chatDetail)
+                        .withInt("type", V2TIMConversation.V2TIM_C2C)
+                        .withString("account", conversationInfo?.id)
+                        .withString("chatName", conversationInfo?.title)
+                        .withString("headSpecial" , model.android_head_special)
+                        .navigation()
+                }
+              jumpDetail = false
             }
         }
     }
@@ -68,4 +71,9 @@ class MessageListDialog : BaseXDFragment<DialogMessageListBinding>() {
         ConversationManagerKit.getInstance().detachAdapter()
         super.onDestroyView()
     }
+
+    override fun onResume() {
+        super.onResume()
+        jumpDetail = true
+    }
 }