Sfoglia il codice sorgente

1、实时刷新订单小圆点

yzs 4 anni fa
parent
commit
5ac0aafa1f

+ 28 - 16
app/src/main/java/com/shanp/youqi/app/fragment/ChatMessageListFragmentKotlin.kt

@@ -15,7 +15,6 @@ import com.blankj.utilcode.util.NetworkUtils.OnNetworkStatusChangedListener
 import com.chad.library.adapter.base.BaseQuickAdapter
 import com.shanp.youqi.R
 import com.shanp.youqi.app.activity.InteractiveMessageListActivity
-import com.shanp.youqi.app.activity.UQChatMsgActivity
 import com.shanp.youqi.app.adapter.UChatMessageListAdapter
 import com.shanp.youqi.base.image.CustomTransformation
 import com.shanp.youqi.base.image.ImageLoader
@@ -54,7 +53,6 @@ import kotlinx.coroutines.GlobalScope
 import kotlinx.coroutines.launch
 import kotlinx.coroutines.withContext
 import java.util.*
-import java.util.regex.Pattern
 import kotlin.concurrent.thread
 
 /**
@@ -188,8 +186,9 @@ class ChatMessageListFragmentKotlin : UChatFragment() {
 
                     headerBinding.rlOrderMessageLayout -> {
                         ARouterFun.startPlayOrderList(1)
-                        headerBinding.tvOrderMessageNumber.text = "0"
-                        headerBinding.tvOrderMessageNumber.visibility = View.INVISIBLE
+                        IMCore.get().resetUnreadTime()
+//                        headerBinding.tvOrderMessageNumber.text = "0"
+//                        headerBinding.tvOrderMessageNumber.visibility = View.INVISIBLE
                     }
 
                     headerBinding.civLiveUser, headerBinding.tvLiveUser -> ARouterFun.startUserLike(1)
@@ -219,6 +218,10 @@ class ChatMessageListFragmentKotlin : UChatFragment() {
                         getSystemConversation()
                     } else if (it.conversationType == Conversation.ConversationType.PRIVATE) {
                         disposeMessage(it)
+                        if (it.objectName == C.im.IM_MESSAGE_TAG_PLAY_ORDER_TYPE) {
+                            IMCore.get().resetUnreadTime()
+                            refresh()
+                        }
                     }
                 }
             }
@@ -620,7 +623,7 @@ class ChatMessageListFragmentKotlin : UChatFragment() {
     }
 
     /**
-     * ---------------- 这是头部数据 -----------------------------------------------------------
+     * ---------------- 头部数据 -----------------------------------------------------------
      */
 
     private fun setFindBossIsSow() {
@@ -689,10 +692,10 @@ class ChatMessageListFragmentKotlin : UChatFragment() {
     private fun loadAvatar(iv: ImageView, ivMask: ImageView, url: String, isLikeMe: Boolean) {
         val userMine = AppManager.get().userMine ?: return
         if (isLikeMe) {
-            val isExplotionLight = !userMine.isExplotionLight
-            if (isExplotionLight) ImageLoader.get().load(url, iv, CustomTransformation.builder().blur(10))
+            val isExplosionLight = !userMine.isExplotionLight
+            if (isExplosionLight) ImageLoader.get().load(url, iv, CustomTransformation.builder().blur(10))
             else ImageLoader.get().loadAvatar(url, iv)
-            ivMask.visibility = if (isExplotionLight) View.VISIBLE else View.GONE
+            ivMask.visibility = if (isExplosionLight) View.VISIBLE else View.GONE
         } else {
             val isPlayer = userMine.playerAuthentication == "1" // 1 是陪玩师
             val showMask = !isPlayer && !userMine.isExplotionLight
@@ -723,15 +726,24 @@ class ChatMessageListFragmentKotlin : UChatFragment() {
      */
     private fun setOrderUnreadNum(orderUnreadNum: Int) {
         var unreadNum = orderUnreadNum
-        if (unreadNum == -1) {
-            val s: String = headerBinding.tvOrderMessageNumber.text.toString()
-            unreadNum = when {
-                Pattern.matches("[0-9]+", s) -> (s.toInt() + 1)
-                TextUtils.isEmpty(s) -> 1
-                else -> 1
-            }
+        var unreadNumStr = unreadNum.toString()
+        if (unreadNum > 99) {
+            unreadNumStr = "99+"
+//            val s: String = headerBinding.tvOrderMessageNumber.text.toString()
+//            unreadNum = when {
+//                Pattern.matches("[0-9]+", s) -> {
+//                    val num = s.toInt()
+//                    if (num > 0) {
+//                        num + unreadNum
+//                    } else {
+//                        0
+//                    }
+//                }
+//                TextUtils.isEmpty(s) -> 0
+//                else -> 0
+//            }
         }
-        headerBinding.tvOrderMessageNumber.text = unreadNum.toString()
+        headerBinding.tvOrderMessageNumber.text = unreadNumStr
         headerBinding.tvOrderMessageNumber.visibility = if (unreadNum > 0) View.VISIBLE else View.INVISIBLE
     }