Pārlūkot izejas kodu

用户信息弹框

tongmengxiao 5 mēneši atpakaļ
vecāks
revīzija
85e5f5556f

+ 7 - 2
baseswago/src/main/java/com/swago/baseswago/PersonDataDFragment.kt

@@ -38,6 +38,7 @@ class PersonDataDFragment : BaseXDFragment<DialogPersonDataBinding>() {
     var roomId:String = ""
     var isAnchor = false //是否是主播点击了资料卡
     var isAdmin = false
+    var isMessage = false
     private var inRoom = false
     private var isForbid = 0 //0没有被禁言  1已被禁言
     var openGiftDialog:((nickName:String,userId:String)->Unit)? = null
@@ -45,13 +46,14 @@ class PersonDataDFragment : BaseXDFragment<DialogPersonDataBinding>() {
     var sendMsgInRoom:((nickName:String)->Unit)? = null
 
     companion object{
-        fun newInstance(uid:String,isAnchor:Boolean=false,inRoom:Boolean=false,roomId:String=""): PersonDataDFragment {
+        fun newInstance(uid:String,isAnchor:Boolean=false,inRoom:Boolean=false,roomId:String="",isMessage:Boolean=false): PersonDataDFragment {
             val dialog = PersonDataDFragment()
             val bundle = Bundle()
             bundle.putString("uid",uid)
             bundle.putBoolean("inRoom",inRoom)
             bundle.putBoolean("isAnchor",isAnchor)
             bundle.putString("roomId",roomId)
+            bundle.putBoolean("isMessage",isMessage)
             dialog.arguments = bundle
             return dialog
         }
@@ -64,13 +66,16 @@ class PersonDataDFragment : BaseXDFragment<DialogPersonDataBinding>() {
             inRoom = it.getBoolean("inRoom")
             isAnchor = it.getBoolean("isAnchor")
             roomId = it.getString("roomId","")
+            isMessage = it.getBoolean("isMessage")
             if (!TextUtils.isEmpty(uid)){
                 userVm.getOtherUserInfo(uid,roomId)
             }
 
             UserInfo.getUserInfo()?.let {
                 if (it.id == uid){
-//                    binding.ivGift.visibility = View.GONE
+                    if (isMessage){
+                        binding.ivGift.visibility = View.GONE
+                    }
                     binding.tvAt.visibility = View.GONE
                     binding.llChat.visibility = View.GONE
                     binding.llToFollow.visibility = View.GONE

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

@@ -10,6 +10,7 @@ import com.alibaba.android.arouter.facade.annotation.Route
 import com.alibaba.android.arouter.launcher.ARouter
 import com.google.gson.Gson
 import com.gyf.immersionbar.ImmersionBar
+import com.swago.baseswago.PersonDataDFragment
 import com.swago.baseswago.UserVm
 import com.swago.baseswago.dialog.ReportBlockDialogFragment
 import com.swago.baseswago.activity.BaseXActivity
@@ -20,6 +21,9 @@ import com.swago.baseswago.util.UserInfo
 import com.swago.home.databinding.ActivityChatDetailBinding
 import com.tencent.imsdk.v2.V2TIMConversation
 import com.tencent.qcloud.tim.uikit.modules.chat.base.ChatInfo
+import com.tencent.qcloud.tim.uikit.modules.chat.layout.message.MessageLayout
+import com.tencent.qcloud.tim.uikit.modules.message.MessageInfo
+import com.tencent.qcloud.tim.uikit.utils.ToastUtil
 
 /**
  *@date 2021/8/24 15:01
@@ -76,6 +80,23 @@ class ChatDetailActivity  : BaseXActivity<ActivityChatDetailBinding>() {
             UserInfo.setUserInfo(it)
             SpUtil.putString("user_info", Gson().toJson(it))
         }
+
+        val messageRecyclerView = binding.chatLayout.messageLayout
+        messageRecyclerView.setOnItemClickListener(object : MessageLayout.OnItemLongClickListener{
+            override fun onMessageLongClick(view: View?, position: Int, messageInfo: MessageInfo?) {
+
+            }
+
+            override fun onUserIconClick(view: View?, position: Int, messageInfo: MessageInfo?) {
+                UserInfo.getUserInfo()?.let {
+                    PersonDataDFragment.newInstance(it.id,
+                        isAnchor = false,
+                        inRoom = false,
+                        isMessage = true
+                    ).show(supportFragmentManager,"PersonDataDFragment")
+                }
+            }
+        })
     }
 
     override fun initLiveData() {

+ 7 - 1
room/src/main/java/com/swago/room/base/BaseComFragment.kt

@@ -451,7 +451,13 @@ abstract class BaseComFragment<T : FragmentBaseComBinding> : BaseXFragment<T>(),
         }
 
         (iHeader as ComHeaderView).openAudienceListDialog = {
-            AudienceListDialog.newInstance().show(childFragmentManager, "AudienceListDialog")
+            AudienceListDialog.newInstance().apply {
+                this.showUserInfo = {userid ->
+                   PersonDataDFragment.newInstance(userid,
+                       isAnchor = false,
+                       inRoom = true).show(this@BaseComFragment.childFragmentManager,"PersonDataDFragment")
+                }
+            }.show(childFragmentManager, "AudienceListDialog")
         }
 
         (iHeader as ComHeaderView).showFanClubFun = {

+ 8 - 0
room/src/main/java/com/swago/room/dialog/AudienceListDialog.kt

@@ -29,6 +29,7 @@ import de.hdodenhof.circleimageview.CircleImageView
 class AudienceListDialog : BaseListDialogFragment<DialogAudienceListBinding,RoomUserModel.ListBean>() {
 
     private val roomVm by activityViewModels<RoomVm>()
+    var showUserInfo:((id:String)->Unit)? = null
 
     init {
         setGravity(Gravity.BOTTOM)
@@ -75,6 +76,13 @@ class AudienceListDialog : BaseListDialogFragment<DialogAudienceListBinding,Room
 
            }
        }
+
+        adapter.setOnItemClickListener { _, _, position ->
+            if (adapter.data.size>position){
+                showUserInfo?.invoke(adapter.data[position].user_id)
+                dismissAllowingStateLoss()
+            }
+        }
     }