tongmengxiao преди 3 месеца
родител
ревизия
cd2feeb50e

+ 12 - 1
app/src/main/java/com/swago/app/SplashActivity.kt

@@ -1,6 +1,7 @@
 package com.swago.app
 
 import android.Manifest
+import android.content.Intent
 import android.os.Build
 import android.os.Bundle
 import android.os.CountDownTimer
@@ -142,6 +143,7 @@ class SplashActivity : AppCompatActivity() {
             if (it == null || TextUtils.isEmpty(it.rotation_img_url)){
                 splashVm.loginByAuto()
             } else {
+                configModel = it
                 mSplashImage?.loadNoPlaceUrl(this, it.rotation_img_url) { success ->
                     if (success){
                         mSplashTime?.visibility = View.VISIBLE
@@ -157,10 +159,11 @@ class SplashActivity : AppCompatActivity() {
 
         mSplashImage?.setOnClickListener(object :NoDoubleClickListener() {
             override fun onClick() {
+                countDownTimer.cancel()
                 configModel?.rotation_url?.let {
                     ARouter.getInstance().build(ARouteConstant.Base.webView)
                         .withString("url", it)
-                        .navigation()
+                        .navigation(this@SplashActivity,1001)
                 }
             }
         })
@@ -185,4 +188,12 @@ class SplashActivity : AppCompatActivity() {
         super.onDestroy()
         countDownTimer.cancel()
     }
+
+    override fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent?) {
+        super.onActivityResult(requestCode, resultCode, data)
+        if (requestCode == 1001){
+            isRunning = false
+            splashVm.loginByAuto()
+        }
+    }
 }

+ 2 - 0
baseswago/src/main/java/com/swago/baseswago/activity/WebViewActivity.kt

@@ -199,10 +199,12 @@ class WebViewActivity : BaseXActivity<ActivityWebBinding>() {
                     if (it.contains(url)  || it.contains("withdrawal")) {
                         webView.goBack()
                     } else {
+                        setResult(RESULT_OK)
                         finish()
                     }
                 }
             } else {
+                setResult(RESULT_OK)
                 finish()
             }
         }

+ 10 - 1
baseswago/src/main/java/com/swago/baseswago/im/GroupMsgParser.kt

@@ -52,6 +52,7 @@ import com.swago.baseswago.im.ImConstant.room_dan_mu
 import com.swago.baseswago.im.ImConstant.send_wish_gift
 import com.swago.baseswago.im.ImConstant.set_room_admin
 import com.swago.baseswago.im.ImConstant.svg_gift
+import com.swago.baseswago.im.ImConstant.system_message
 import com.swago.baseswago.im.ImConstant.today_star_rewards
 import com.swago.baseswago.im.ImConstant.update_audience
 import com.swago.baseswago.im.ImConstant.update_mic_list_data
@@ -62,6 +63,7 @@ import com.swago.baseswago.im.ImConstant.user_join_room
 import com.swago.baseswago.im.ImConstant.user_like
 import com.swago.baseswago.im.ImConstant.user_refuse_invite_by_anchor
 import com.swago.baseswago.model.RedEnvelope
+import com.swago.baseswago.model.home.OfficialSumModel
 import com.swago.baseswago.model.im.*
 import com.swago.baseswago.model.live.ForceCloseModel
 import com.swago.baseswago.model.live.ReceiveModel
@@ -413,7 +415,14 @@ class GroupMsgParser : IGroupNewMsgParser {
                     )
                     parserModel = gson.fromJson(resultString,parameterizedTypeImpl)
                 }
-
+                system_message -> {
+                    parameterizedTypeImpl = ParameterizedTypeImpl(
+                        arrayOf<Type>(OfficialSumModel::class.java),
+                        CusNewMsgBean::class.java,
+                        CusNewMsgBean::class.java
+                    )
+                    parserModel = gson.fromJson(resultString,parameterizedTypeImpl)
+                }
             }
             parserModel?.v2TIMMessage = v2TIMMessage
         }catch (e:Exception){

+ 4 - 0
baseswago/src/main/java/com/swago/baseswago/im/ImConstant.kt

@@ -262,6 +262,10 @@ object ImConstant {
      * 砸金蛋奖池金额
      * */
     const val break_egg_sum = 508
+    /**
+     * 系统消息
+     * */
+    const val system_message = 509
 
 
     /**********游戏相关IM********/

+ 9 - 1
baseswago/src/main/java/com/swago/baseswago/model/UnreadMessageVm.kt

@@ -6,11 +6,19 @@ import com.swago.baseswago.util.BaseViewModel
 
 class UnreadMessageVm (application: Application) : BaseViewModel(application){
 
+    var imMessage = 0L
+    var systemMessage = 0L
+
     val unreadMessageData by lazy {
         MutableLiveData<Long>()
     }
 
     fun setTotalUnreadCount(count: Long) {
-        unreadMessageData.value = count
+        imMessage = count
+        unreadMessageData.value = imMessage + systemMessage
+    }
+    fun setSystemUnreadCount(count: Long){
+        systemMessage = count
+        unreadMessageData.value = imMessage + systemMessage
     }
 }

+ 2 - 1
baseswago/src/main/java/com/swago/baseswago/model/home/OfficialSumModel.kt

@@ -7,5 +7,6 @@ package com.swago.baseswago.model.home
 data class OfficialSumModel(
     val message_content:String,
     val unread_total:String,
-    val message_time:String
+    val message_time:String,
+    val unreadTotal:Long
 )

+ 5 - 15
baseswago/src/main/java/com/swago/baseswago/util/IMUtil.kt

@@ -89,21 +89,11 @@ object IMUtil {
     /**
      * 未读消息数
      * */
-    fun updateUnreadMessageCount(call:(total:Long)->Unit){
-        V2TIMManager.getConversationManager().getTotalUnreadMessageCount(object :V2TIMValueCallback<Long>{
-            override fun onSuccess(totalUnreadCount: Long) {
-                call.invoke(totalUnreadCount)
-            }
-
-            override fun onError(code: Int, desc: String?) {
+    fun updateUnreadMessageCount(conversationListener: V2TIMConversationListener){
+        V2TIMManager.getConversationManager().addConversationListener(conversationListener)
+    }
 
-            }
-        })
-        V2TIMManager.getConversationManager().addConversationListener(object :V2TIMConversationListener(){
-            override fun onTotalUnreadMessageCountChanged(totalUnreadCount: Long) {
-                super.onTotalUnreadMessageCountChanged(totalUnreadCount)
-                call.invoke(totalUnreadCount)
-            }
-        })
+    fun removeConversationListener(conversationListener: V2TIMConversationListener){
+        V2TIMManager.getConversationManager().removeConversationListener(conversationListener)
     }
 }

+ 3 - 3
baseswago/src/main/res/values-in/strings.xml

@@ -126,9 +126,9 @@
     <string name="live_room_black">Daftar hitam live room</string>
     <string name="anchor_black">Daftar hitam host</string>
     <string name="edit">mengubah</string>
-    <string name="level">tingkatan</string>
-    <string name="withdrawal">withdraw</string>
-    <string name="top_up">isi ulang</string>
+    <string name="level">Tingkatan</string>
+    <string name="withdrawal">Withdraw</string>
+    <string name="top_up">Isi ulang</string>
     <string name="app_settings">App Settings</string>
     <string name="nickname">Nickname</string>
     <string name="confirm">Konfirmasi</string>

+ 4 - 4
baseswago/src/main/res/values-ms/strings.xml

@@ -126,10 +126,10 @@
     <string name="live_room_black">senarai hitam siaran langsung</string>
     <string name="anchor_black">senarai hitam host</string>
     <string name="edit">edit</string>
-    <string name="level">tahap</string>
-    <string name="withdrawal">pengeluaran</string>
-    <string name="top_up">tambah nilai</string>
-    <string name="app_settings">sediakan</string>
+    <string name="level">Tahap</string>
+    <string name="withdrawal">Pengeluaran</string>
+    <string name="top_up">Tambah nilai</string>
+    <string name="app_settings">Sediakan</string>
     <string name="nickname">nama pangilan</string>
     <string name="confirm">mengesahkan</string>
     <string name="say_hi">kata hi</string>

+ 1 - 1
baseswago/src/main/res/values/strings.xml

@@ -368,7 +368,7 @@
     <string name="select_all">Select all</string>
     <string name="add_to_my_music">Add to my music</string>
     <string name="sure_delete_this_music">Are you sure you want to delete this music?</string>
-    <string name="dress_up">my decorations</string>
+    <string name="dress_up">My decorations</string>
     <string name="mall">Mall</string>
     <string name="buy_it_now">Buy it now</string>
     <string name="beauty_filter">beauty&amp;filter</string>

+ 21 - 4
home/src/main/java/com/swago/home/HomeActivity.kt

@@ -31,6 +31,7 @@ import com.swago.home.databinding.ActivityHomeBinding
 import com.swago.home.innerhome.HomeVm
 import com.swago.home.official.OfficialVm
 import com.swago.home.update.UpdateDialog
+import com.tencent.imsdk.v2.V2TIMConversationListener
 import com.tencent.qcloud.tim.uikit.TUIKit
 import com.tencent.qcloud.tim.uikit.base.IUIKitCallBack
 import com.tencent.qcloud.tim.uikit.config.TUIKitConfigs
@@ -51,6 +52,7 @@ class HomeActivity : BaseXActivity<ActivityHomeBinding>(), IPayCallback {
     private val payVm by viewModels<PayVm>()
     private lateinit var unreadMessageVm: UnreadMessageVm
     private var messageFragment: MessageFragment? = null
+    private var conversationListener: V2TIMConversationListener?=null
 
     private val listFragment =
         arrayListOf(HomeFragment(), MessageFragment(), MineFragment())
@@ -61,7 +63,7 @@ class HomeActivity : BaseXActivity<ActivityHomeBinding>(), IPayCallback {
 
     override fun initOther() {
         unreadMessageVm = ViewModelProviderUtil.getUnreadMessageViewModel(application)
-        TUIKit.init(this, UrlConstant.getImId(), TUIKitConfigs.getConfigs())
+        TUIKit.init(application, UrlConstant.getImId(), TUIKitConfigs.getConfigs())
         PayManager.init()
         IMMessageManager.groupMessageParser.add(GroupMsgParser())
         SpUtil.putInt("isHomeBack" , 1)
@@ -133,6 +135,16 @@ class HomeActivity : BaseXActivity<ActivityHomeBinding>(), IPayCallback {
             }
 
         }
+        conversationListener = object : V2TIMConversationListener(){
+            override fun onTotalUnreadMessageCountChanged(totalUnreadCount: Long) {
+                super.onTotalUnreadMessageCountChanged(totalUnreadCount)
+                unreadMessageVm.setTotalUnreadCount(totalUnreadCount)
+            }
+        }
+        IMUtil.updateUnreadMessageCount(conversationListener!!)
+        homeVm.systemMessageFun = {
+            unreadMessageVm.setSystemUnreadCount(it.unreadTotal)
+        }
     }
 
     /**
@@ -304,9 +316,6 @@ class HomeActivity : BaseXActivity<ActivityHomeBinding>(), IPayCallback {
                 IUIKitCallBack {
                 override fun onSuccess(data: Any?) {
                     IMUtil.joinGroup(null)
-                    IMUtil.updateUnreadMessageCount {unread->
-                        unreadMessageVm.setTotalUnreadCount(unread)
-                    }
                 }
 
                 override fun onError(module: String?, errCode: Int, errMsg: String?) {
@@ -320,4 +329,12 @@ class HomeActivity : BaseXActivity<ActivityHomeBinding>(), IPayCallback {
             })
         }
     }
+
+    override fun onDestroy() {
+        super.onDestroy()
+        if (conversationListener != null) {
+            IMUtil.removeConversationListener(conversationListener!!)
+            conversationListener = null
+        }
+    }
 }

+ 10 - 0
home/src/main/java/com/swago/home/innerhome/HomeVm.kt

@@ -7,9 +7,11 @@ import com.swago.baseswago.im.IMGroupNewMsgListener
 import com.swago.baseswago.im.ImConstant.bind_anchor
 import com.swago.baseswago.im.ImConstant.change_user_name
 import com.swago.baseswago.im.ImConstant.close_account
+import com.swago.baseswago.im.ImConstant.system_message
 import com.swago.baseswago.inter.ApiManager
 import com.swago.baseswago.model.MomentModel
 import com.swago.baseswago.model.home.BannerModel
+import com.swago.baseswago.model.home.OfficialSumModel
 import com.swago.baseswago.model.im.BindAnchorData
 import com.swago.baseswago.model.im.ChangeNameData
 import com.swago.baseswago.model.im.CloseAccountData
@@ -26,6 +28,7 @@ class HomeVm(application: Application) : BaseViewModel(application) {
 
     var bindAnchorFun:((data: BindAnchorData) -> Unit)? = null
     var closeAccountFun:((data: CloseAccountData) -> Unit)? = null
+    var systemMessageFun:((data: OfficialSumModel) -> Unit)? = null
 
     val imGroupNewMsgListener = IMGroupNewMsgListener()
 
@@ -59,6 +62,13 @@ class HomeVm(application: Application) : BaseViewModel(application) {
                 }
             }
         }
+        imGroupNewMsgListener.handleMsgType<CusNewMsgBean<OfficialSumModel>>(
+            system_message
+        ){
+            it.data?.let {model ->
+                systemMessageFun?.invoke(model)
+            }
+        }
     }
 
     override fun onCleared() {

+ 5 - 0
home/src/main/java/com/swago/home/official/OfficialMessageActivity.kt

@@ -8,6 +8,8 @@ import com.chad.library.adapter.base.BaseQuickAdapter
 import com.swago.baseswago.activity.BaseListActivity
 import com.swago.baseswago.cusview.SwagoRecyclerView
 import com.swago.baseswago.dialog.InviteBindingDialog
+import com.swago.baseswago.model.UnreadMessageVm
+import com.swago.baseswago.model.ViewModelProviderUtil
 import com.swago.baseswago.model.home.OfficialMsgModel
 import com.swago.baseswago.model.im.BindAnchorData
 import com.swago.baseswago.util.AppContext
@@ -22,6 +24,7 @@ class OfficialMessageActivity : BaseListActivity<ActivityOfficialMessageBinding,
 
     private val officialVm by viewModels<OfficialVm>()
     private lateinit var inviteData: BindAnchorData
+    private lateinit var unreadMessageVm: UnreadMessageVm
 
     override val smartRecyclerView: SwagoRecyclerView<OfficialMsgModel.ListBean> by lazy {
         binding.swagoRv as SwagoRecyclerView<OfficialMsgModel.ListBean>
@@ -63,5 +66,7 @@ class OfficialMessageActivity : BaseListActivity<ActivityOfficialMessageBinding,
             InviteBindingDialog.newInstance(inviteData)
                 .show(supportFragmentManager, "InviteBindingDialog")
         }
+        unreadMessageVm = ViewModelProviderUtil.getUnreadMessageViewModel(application)
+        unreadMessageVm.setSystemUnreadCount(0)
     }
 }

+ 4 - 0
login/src/main/java/com/swago/login/FBLogin.kt

@@ -44,6 +44,10 @@ object FBLogin {
         LoginManager.getInstance().logInWithReadPermissions(activity, listOf("public_profile"))
     }
 
+    fun unregisterCallback(){
+        LoginManager.getInstance().unregisterCallback(manager)
+    }
+
     fun onActivityResult(requestCoe: Int, resultCode: Int, data: Intent) {
         manager.onActivityResult(requestCoe, resultCode, data)
     }

+ 5 - 0
login/src/main/java/com/swago/login/LoginActivity.kt

@@ -338,4 +338,9 @@ class LoginActivity : BaseXActivity<ActivityLoginBinding>() {
             }
         }
     }
+
+    override fun onDestroy() {
+        super.onDestroy()
+        FBLogin.unregisterCallback()
+    }
 }