Bladeren bron

fix: 内存泄露 person dialog

tongmengxiao 5 maanden geleden
bovenliggende
commit
9002513611

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

@@ -159,9 +159,11 @@ class PersonDataDFragment : BaseXDFragment<DialogPersonDataBinding>() {
 
             binding.ivMore.setOnClickListener(object:NoDoubleClickListener(){
                 override fun onClick() {
-                    HandleDialogFragment.newInstance(uid,account,isForbid,isAnchor,inRoom,isAdmin){
-                        if (!TextUtils.isEmpty(uid)){
-                            userVm.getOtherUserInfo(uid,roomId)
+                    HandleDialogFragment.newInstance(uid,account,isForbid,isAnchor,inRoom,isAdmin).apply {
+                        this.refreshCallBack = {
+                            if (!TextUtils.isEmpty(uid)){
+                                userVm.getOtherUserInfo(uid,roomId)
+                            }
                         }
                     }.show(childFragmentManager,"HandleDialogFragment")
                 }

+ 2 - 3
baseswago/src/main/java/com/swago/baseswago/dialog/HandleDialogFragment.kt

@@ -29,6 +29,7 @@ class HandleDialogFragment : BaseXDFragment<DialogHandleBinding>() {
     private var inRoom = false
     private var isAnchor = false
     private var isRoomAdmin = false
+    var refreshCallBack:(()->Unit)? = null
 
 
     init {
@@ -38,9 +39,7 @@ class HandleDialogFragment : BaseXDFragment<DialogHandleBinding>() {
 
 
     companion object{
-        private var refreshCallBack:(()->Unit)? = null
-        fun newInstance(userId:String,account:String,isForbid:Int,isAnchor:Boolean,inRoom:Boolean=false,isRoomAdmin:Boolean=false,refreshCallBack:(()->Unit)? = null): HandleDialogFragment {
-            this.refreshCallBack = refreshCallBack
+        fun newInstance(userId:String,account:String,isForbid:Int,isAnchor:Boolean,inRoom:Boolean=false,isRoomAdmin:Boolean=false): HandleDialogFragment {
             val args = Bundle()
             args.putString("userId",userId)
             args.putString("account",account)

BIN
baseswago/src/main/res/mipmap-xxhdpi/ic_audio_lock.png


BIN
baseswago/src/main/res/mipmap-xxhdpi/ic_audio_lock.webp


BIN
baseswago/src/main/res/mipmap-xxhdpi/ic_audio_seat.png


BIN
baseswago/src/main/res/mipmap-xxhdpi/ic_audio_seat.webp


+ 0 - 9
home/src/main/java/com/swago/home/ChatDetailActivity.kt

@@ -125,15 +125,6 @@ class ChatDetailActivity  : BaseXActivity<ActivityChatDetailBinding>() {
             }
         })
 
-        if (UserInfo.getUserInfo() != null && !TextUtils.isEmpty(UserInfo.getUserInfo()?.android_chat_special)){
-            UserInfo.getUserInfo()?.android_chat_special?.let {chatUrl ->
-                DianJiuUtil.loadDian9Tu(this ,chatUrl ){ drawable ->
-                    drawable?.let {
-                        messageRecyclerView?.rightBubble = it
-                    }
-                }
-            }
-        }
         if (!TextUtils.isEmpty(headSpecial)){
             svgaParser?.decodeFromURL(URL(headSpecial), object :SVGAParser.ParseCompletion{
                 override fun onComplete(videoItem: SVGAVideoEntity) {

+ 11 - 19
room/src/main/java/com/swago/room/base/BaseComFragment.kt

@@ -5,7 +5,6 @@ import android.graphics.Rect
 import android.text.TextUtils
 import android.util.Log
 import android.view.View
-import android.view.ViewGroup
 import android.widget.ImageView
 import android.widget.TextView
 import android.widget.Toast
@@ -26,7 +25,6 @@ import com.liulishuo.okdownload.core.cause.ResumeFailedCause
 import com.permissionx.guolindev.PermissionX
 import com.swago.baseswago.PersonDataDFragment
 import com.swago.baseswago.UserVm
-import com.swago.baseswago.agora.AgoraManager
 import com.swago.baseswago.baseroom.*
 import com.swago.baseswago.constant.ARouteConstant
 import com.swago.baseswago.constant.UrlConstant
@@ -60,8 +58,6 @@ import com.swago.room.databinding.FragmentBaseComBinding
 import com.swago.room.dialog.AudienceListDialog
 import com.swago.room.dialog.FanClubAnchorDialog
 import com.swago.room.dialog.FanClubForUserDialog
-import com.swago.room.dialog.FooterMoreDialog
-import com.swago.room.dialog.HouseGoLiveDialog
 import com.swago.room.dialog.JoinFanClubDialog
 import com.swago.room.dialog.LevelUpDialog
 import com.swago.room.dialog.MessageListDialog
@@ -96,7 +92,6 @@ import kotlinx.coroutines.CoroutineScope
 import kotlinx.coroutines.Dispatchers
 import kotlinx.coroutines.GlobalScope
 import kotlinx.coroutines.Job
-import kotlinx.coroutines.cancel
 import kotlinx.coroutines.delay
 import kotlinx.coroutines.isActive
 import kotlinx.coroutines.launch
@@ -148,9 +143,7 @@ abstract class BaseComFragment<T : FragmentBaseComBinding> : BaseXFragment<T>(),
     val job = Job()
     val coroutineScope = CoroutineScope(Dispatchers.Main + job)
 
-    var dialog: SendMsgDialog? = null
     var gameDialog: GamePlayDialog? = null
-    var msgListDialog: MessageListDialog? = null
 
     val gameList by lazy {
         ArrayList<GameModel>()
@@ -649,7 +642,10 @@ abstract class BaseComFragment<T : FragmentBaseComBinding> : BaseXFragment<T>(),
 
         msgVm.joinRoomFun = {
             //svg播放
-            joinAnimalManager.addSvgUrl(it)
+            if (!it.androidJoinSpecial.isNullOrEmpty()){
+                joinAnimalManager.addSvgUrl(it)
+            }
+
         }
 
         userVm.userInfoLiveData.observe(this) {
@@ -769,9 +765,7 @@ abstract class BaseComFragment<T : FragmentBaseComBinding> : BaseXFragment<T>(),
 
     override fun onDestroyView() {
         super.onDestroyView()
-        dialog = null
         gameDialog = null
-        msgListDialog = null
         job.cancel()
         PKStateManager.removePKListener(this)
         activity?.let {
@@ -782,11 +776,11 @@ abstract class BaseComFragment<T : FragmentBaseComBinding> : BaseXFragment<T>(),
     }
 
     fun openSendMessageDialog(atName: String = "") {
-        dialog = SendMsgDialog.newInstance(atName)
-        dialog?.addSenderMsgToRoomChatList = {
-            addChatMsgToRv(it)
-        }
-        dialog?.show(childFragmentManager, "SendMsgDialog")
+        SendMsgDialog.newInstance(atName).apply {
+            this.addSenderMsgToRoomChatList = {
+                addChatMsgToRv(it)
+            }
+        }.show(childFragmentManager, "SendMsgDialog")
     }
 
     fun openMoreDialog(){
@@ -801,8 +795,7 @@ abstract class BaseComFragment<T : FragmentBaseComBinding> : BaseXFragment<T>(),
     }
 
     fun openMessageListDialog() {
-        msgListDialog = MessageListDialog.newInstance()
-        msgListDialog?.show(childFragmentManager, "MessageListDialog")
+       MessageListDialog.newInstance().show(childFragmentManager, "MessageListDialog")
     }
 
     private var gameIsOpen = false
@@ -933,9 +926,7 @@ abstract class BaseComFragment<T : FragmentBaseComBinding> : BaseXFragment<T>(),
 
     override fun leaveRoom(iRoomInfo: IRoomInfo) {
         dataChatList.clear()
-        dialog = null
         gameDialog = null
-        msgListDialog = null
         chatAdapter.notifyDataSetChanged()
         if (iRoomInfo.getRoomType() == RoomType.AUDIO.type){
             val data = ArrayList<AudioSeatModel>()
@@ -946,6 +937,7 @@ abstract class BaseComFragment<T : FragmentBaseComBinding> : BaseXFragment<T>(),
 
     override fun closeRoomed() {
         binding.likeLayout.clear()
+        gameDialog = null
         RoomTimer.timeTickList.remove(this)
     }
 

+ 17 - 18
room/src/main/java/com/swago/room/dialog/MessageListDialog.kt

@@ -41,34 +41,33 @@ class MessageListDialog : BaseXDFragment<DialogMessageListBinding>() {
 
 
     override fun initOther() {
-        activity?.let {
-            binding.conversation.initDefault()
-            binding.conversation.conversationList.setOnItemClickListener { view, position, messageInfo ->
-                conversationInfo = messageInfo
-                userVm.getOtherUserInfo(messageInfo.id,"")
-            }
+        binding.conversation.initDefault()
+        binding.conversation.conversationList.setOnItemClickListener { view, position, messageInfo ->
+            conversationInfo = messageInfo
+            userVm.getOtherUserInfo(messageInfo.id,"")
+        }
 
-            binding.conversation.conversationList.setOnItemLongClickListener { view, position, messageInfo ->
+        binding.conversation.conversationList.setOnItemLongClickListener { view, position, messageInfo ->
 
-            }
+        }
 
-            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
+        userVm.otherUserInfoLiveData.observe(viewLifecycleOwner){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
         }
     }
 
     override fun initLiveData() {}
     override fun onDestroyView() {
         ConversationManagerKit.getInstance().detachAdapter()
+        userVm.otherUserInfoLiveData.removeObservers(viewLifecycleOwner)
         super.onDestroyView()
     }
 

+ 6 - 1
room/src/main/java/com/swago/room/dialog/SendMsgDialog.kt

@@ -217,12 +217,17 @@ class SendMsgDialog : BaseXDFragment<DialogSendMsgBinding>() {
     }
 
     override fun initLiveData() {
-        roomOtherVm.sendDanMuResultLiveData.observe(this){
+        roomOtherVm.sendDanMuResultLiveData.observe(viewLifecycleOwner){
             SwagoLoading.cancelLoadingDialog()
             dismissAllowingStateLoss()
         }
     }
 
+    override fun onDestroyView() {
+        roomOtherVm.sendDanMuResultLiveData.removeObservers(viewLifecycleOwner)
+        super.onDestroyView()
+    }
+
     override fun dismiss() {
         binding.et.setText("")
         super.dismiss()

+ 6 - 0
room/src/main/java/com/swago/room/gift/control/XSvgPlayer.kt

@@ -90,6 +90,12 @@ class XSvgPlayer : ConstraintLayout {
         if (userJoinRoomBean == null || userJoinRoomBean.androidJoinSpecial.isNullOrEmpty()){
             return
         }
+        if (Regex("%E8%B1%AA%E5%8D%8E%E6%B8%B8%E8%BD%AE").containsMatchIn(userJoinRoomBean.androidJoinSpecial)){
+            binding?.svgaImageView?.layoutParams = ( binding?.svgaImageView?.layoutParams as MarginLayoutParams).apply {
+                bottomMargin = -155 // 以像素为单位设置底部边距
+                topMargin = -155 // 以像素为单位设置顶部边距
+            }
+        }
         svgaParser!!.let {
             LogUtil.d("svgPlayer","xxx--$isPlaying")
             it.decodeFromURL(URL(userJoinRoomBean.androidJoinSpecial),object:SVGAParser.ParseCompletion{

+ 2 - 1
tuikit/src/main/java/com/tencent/qcloud/tim/uikit/modules/conversation/holder/ConversationCommonHolder.java

@@ -12,6 +12,7 @@ import android.widget.TextView;
 
 import com.bumptech.glide.Glide;
 import com.opensource.svgaplayer.SVGAImageView;
+import com.swago.baseswago.util.AppContext;
 import com.tencent.imsdk.v2.V2TIMManager;
 import com.tencent.imsdk.v2.V2TIMUserFullInfo;
 import com.tencent.imsdk.v2.V2TIMValueCallback;
@@ -159,7 +160,7 @@ public class ConversationCommonHolder extends ConversationBaseHolder {
         }
 
         if (conversation.getLastMessage() != null && conversation.getLastMessage().getTimMessage() != null) {
-            Glide.with(itemView.getContext()).load(conversation.getConversationFaceUrl())
+            Glide.with(AppContext.getContext()).load(conversation.getConversationFaceUrl())
                     .placeholder(R.mipmap.default_avatar)
                     .error(R.mipmap.default_avatar).into(conversationIconView);
 

+ 29 - 24
user/src/main/java/com/swago/user/store/StoreBuyDialog.kt

@@ -60,32 +60,38 @@ class StoreBuyDialog : BaseXDFragment<DialogStoreDetailBinding>(){
                 binding.ivIcon.visibility = View.GONE
                 binding.svgContent.visibility = View.VISIBLE
                 binding.svgAvatar.visibility = View.GONE
-                svgaParser?.decodeFromURL(URL(it.product_svg_url), object : SVGAParser.ParseCompletion{
-                    override fun onComplete(videoItem: SVGAVideoEntity) {
-                        val drawable = SVGADrawable(videoItem)
-                        binding.svgContent.visibility = View.VISIBLE
-                        binding.svgAvatar.visibility = View.GONE
-                        binding.svgContent.setImageDrawable(drawable)
-                        binding.svgContent.startAnimation()
-                    }
-                    override fun onError() {
-                    }
-                })
+                it.product_svg_url?.let { svgUrl ->
+                    svgaParser?.decodeFromURL(URL(svgUrl), object : SVGAParser.ParseCompletion{
+                        override fun onComplete(videoItem: SVGAVideoEntity) {
+                            val drawable = SVGADrawable(videoItem)
+                            binding.svgContent.visibility = View.VISIBLE
+                            binding.svgAvatar.visibility = View.GONE
+                            binding.svgContent.setImageDrawable(drawable)
+                            binding.svgContent.startAnimation()
+                        }
+                        override fun onError() {
+                        }
+                    })
+                }
+
             } else if (storeType == 2){
                 binding.ivIcon.visibility = View.GONE
                 binding.svgContent.visibility = View.GONE
                 binding.svgAvatar.visibility = View.VISIBLE
-                svgaParser?.decodeFromURL(URL(it.product_svg_url), object : SVGAParser.ParseCompletion{
-                    override fun onComplete(videoItem: SVGAVideoEntity) {
-                        val drawable = SVGADrawable(videoItem)
-                        binding.svgContent.visibility = View.GONE
-                        binding.svgAvatar.visibility = View.VISIBLE
-                        binding.svgAvatar.setImageDrawable(drawable)
-                        binding.svgAvatar.startAnimation()
-                    }
-                    override fun onError() {
-                    }
-                })
+                it.product_svg_url?.let { svgUrl ->
+                    svgaParser?.decodeFromURL(URL(svgUrl), object : SVGAParser.ParseCompletion{
+                        override fun onComplete(videoItem: SVGAVideoEntity) {
+                            val drawable = SVGADrawable(videoItem)
+                            binding.svgContent.visibility = View.GONE
+                            binding.svgAvatar.visibility = View.VISIBLE
+                            binding.svgAvatar.setImageDrawable(drawable)
+                            binding.svgAvatar.startAnimation()
+                        }
+                        override fun onError() {
+                        }
+                    })
+                }
+
             }else {
                 binding.svgContent.visibility = View.GONE
                 binding.svgAvatar.visibility = View.GONE
@@ -110,7 +116,6 @@ class StoreBuyDialog : BaseXDFragment<DialogStoreDetailBinding>(){
                         return@let
                     }
                     storeVm.buyProduct(it.id)
-                    dismissAllowingStateLoss()
                 }
 
             }
@@ -123,7 +128,7 @@ class StoreBuyDialog : BaseXDFragment<DialogStoreDetailBinding>(){
             if (it){
                 buySuccessFun?.invoke()
             }
-
+            dismissAllowingStateLoss()
         }
     }
 }

+ 6 - 4
user/src/main/res/layout/dialog_store_detail.xml

@@ -12,10 +12,12 @@
             app:autoPlay="true"
             app:fillMode="Forward"
             android:visibility="gone"
-            tools:visibility="gone"
-            app:layout_constraintDimensionRatio="h,1:1"
+            tools:visibility="visible"
+            app:layout_constraintDimensionRatio="h,1:1.5"
             app:layout_constraintBottom_toTopOf="@+id/cl_bottom"
-            app:layout_constraintTop_toTopOf="parent"
+            android:layout_marginBottom="-80dp"
+            android:layout_marginStart="-80dp"
+            android:layout_marginEnd="-80dp"
             app:loopCount="0" />
 
         <androidx.constraintlayout.widget.ConstraintLayout
@@ -66,7 +68,7 @@
                 android:id="@+id/tv_name"
                 android:layout_width="wrap_content"
                 android:layout_height="wrap_content"
-                android:maxWidth="120dp"
+                android:maxWidth="280dp"
                 android:textColor="#ffffff"
                 android:textSize="16sp"
                 android:layout_marginTop="@dimen/dp_10"