Browse Source

fix: share message more

tongmengxiao 5 months ago
parent
commit
04c67eeee9

+ 2 - 6
room/src/main/java/com/swago/room/anchor/AnchorRoomFragment.kt

@@ -54,8 +54,8 @@ class AnchorRoomFragment : BaseComFragment<FragmentBaseComBinding>() {
             openSendMessageDialog()
         }
 
-        footerView?.openMessageFun = {
-            openMessageListDialog()
+        footerView?.openMoreDialog = {
+            openMoreDialog()
         }
 
         footerView?.openGameFun = {
@@ -108,10 +108,6 @@ class AnchorRoomFragment : BaseComFragment<FragmentBaseComBinding>() {
             }
         }
 
-        footerView?.openShareFun = {
-            openShareDialog()
-        }
-
         (iHeader as ComHeaderView).showUserInfo = {
             PersonDataDFragment.newInstance(it, isAnchor = true, inRoom = true,SwagoRoomManager.iRoomInfo?.getRoomId()?:"")
                 .apply {

+ 15 - 2
room/src/main/java/com/swago/room/base/BaseComFragment.kt

@@ -58,6 +58,7 @@ 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
@@ -129,6 +130,7 @@ abstract class BaseComFragment<T : FragmentBaseComBinding> : BaseXFragment<T>(),
 
     //暂时仅用户端使用
     var isForbid = false //是否被禁言
+    var broadcastStatus: Int = 1 //房间状态
 
     abstract val iHeader: IHeader
     abstract val iFooter: IFooter
@@ -180,6 +182,8 @@ abstract class BaseComFragment<T : FragmentBaseComBinding> : BaseXFragment<T>(),
         binding.headFl.addView(iHeader.getHeaderView())
         binding.footerFl.addView(iFooter.getFooterView())
         setHeaderViewPosition()
+        //获取直播间配置
+        roomVm.getRoomConfig(broadcastStatus)
         //初始话语音列表
         initAudioRvList()
         //飘条
@@ -717,6 +721,17 @@ abstract class BaseComFragment<T : FragmentBaseComBinding> : BaseXFragment<T>(),
         dialog?.show(childFragmentManager, "SendMsgDialog")
     }
 
+    fun openMoreDialog(){
+        FooterMoreDialog.newInstance().apply {
+            openMessageFun = {
+                openMessageListDialog()
+            }
+            openShareFun = {
+                openShareDialog()
+            }
+        }.show(childFragmentManager , "FooterMoreDialog")
+    }
+
     fun openMessageListDialog() {
         msgListDialog = MessageListDialog.newInstance()
         msgListDialog?.show(childFragmentManager, "MessageListDialog")
@@ -753,8 +768,6 @@ abstract class BaseComFragment<T : FragmentBaseComBinding> : BaseXFragment<T>(),
     private var isFirst = true
     override fun joinedRoom(iRoomInfo: IRoomInfo) {
         roomOtherVm.getRedEnvelopeList()
-        //获取直播间配置
-        roomVm.getRoomConfig()
         if (iRoomInfo.getRoomType() != RoomType.HOUSE.type){
             roomOtherVm.getFirstWishGiftData(iRoomInfo.getRoomId())
         }

+ 51 - 0
room/src/main/java/com/swago/room/dialog/FooterMoreDialog.kt

@@ -0,0 +1,51 @@
+package com.swago.room.dialog
+
+import android.os.Bundle
+import android.view.Gravity
+import android.view.View
+import android.view.View.OnClickListener
+import androidx.fragment.app.viewModels
+import com.swago.baseswago.baseroom.SwagoRoomManager
+import com.swago.baseswago.dialog.BaseXDFragment
+import com.swago.baseswago.util.NoDoubleClickListener
+import com.swago.baseswago.util.SwagoLoading
+import com.swago.room.bean.UserRoomModel
+import com.swago.room.databinding.DialogAudioNoticeBinding
+import com.swago.room.databinding.DialogFooterMoreBinding
+import com.swago.room.vm.RoomOtherVm
+
+class FooterMoreDialog : BaseXDFragment<DialogFooterMoreBinding>() {
+
+    var openMessageFun:(()->Unit)? = null
+    var openShareFun:(()->Unit)? = null
+
+    init {
+        setGravity(Gravity.BOTTOM)
+        setDimAmount(0.5f)
+        setCanCancel(true)
+    }
+
+    companion object{
+        fun newInstance(): FooterMoreDialog {
+            val args = Bundle()
+            val fragment = FooterMoreDialog()
+            fragment.arguments = args
+            return fragment
+        }
+    }
+
+    override fun initOther() {
+
+    }
+
+    override fun initLiveData() {
+        binding.ivMessage.setOnClickListener {
+            openMessageFun?.invoke()
+            dismissAllowingStateLoss()
+        }
+        binding.ivShare.setOnClickListener {
+            openShareFun?.invoke()
+            dismissAllowingStateLoss()
+        }
+    }
+}

+ 1 - 0
room/src/main/java/com/swago/room/user/UserRoomActivity.kt

@@ -133,6 +133,7 @@ class UserRoomActivity : AbsUserActivity<ActivityAbsRoomUserBinding, UserRoomMod
         mCurrentPosition = position
         RoomDataManager.initData(data)
         userRoomFragment = fragments[1] as UserRoomFragment
+        userRoomFragment?.setBroadcast(data?.get(position)?.user_broadcast_status ?: 1)
 
         roomVm.init()
         msgVm.init()

+ 4 - 0
room/src/main/java/com/swago/room/user/UserRoomFragment.kt

@@ -226,6 +226,10 @@ class UserRoomFragment : BaseComFragment<FragmentBaseComBinding>() {
         }
     }
 
+    fun setBroadcast(broadcastStatus:Int){
+        this.broadcastStatus = broadcastStatus
+    }
+
     override fun changeRoom(iRoomInfo: IRoomInfo) {
         super.changeRoom(iRoomInfo)
 

+ 11 - 11
room/src/main/java/com/swago/room/vm/RoomVm.kt

@@ -103,6 +103,8 @@ class RoomVm(application: Application) : AbsRoomVm(application) {
             requestError {
                 if (it is SwagoException) {
                     if (it.code == 504) {
+                        Toast.makeText(AppContext.getContext(), it.message, Toast.LENGTH_SHORT)
+                            .show()
                         if (SwagoRoomManager.iRoomInfo == null){
                             SwagoRoomManager.closeRoom()
                         }else{
@@ -339,19 +341,17 @@ class RoomVm(application: Application) : AbsRoomVm(application) {
         MutableLiveData<RecommendGameListModel>()
     }
 
-    fun getRoomConfig(){
+    fun getRoomConfig(broadcastStatus : Int){
         requestData {
             //首先获取游戏列表 然后获取直播间配置
-            SwagoRoomManager.iRoomInfo?.let{
-                if (it.getRoomType() == 3){
-                    gameListModelLiveData.value = ApiManager.roomApi.getHouseGameList()
-                    roomConfigLiveData.value = ApiManager.roomApi.getHouseRoomConfig()
-                    recommendGameListModelLiveData.value = ApiManager.roomApi.getHouseRecommendGameList()
-                } else {
-                    gameListModelLiveData.value = ApiManager.roomApi.getGameList()
-                    roomConfigLiveData.value = ApiManager.roomApi.getRoomConfig()
-                    recommendGameListModelLiveData.value = ApiManager.roomApi.getRecommendGameList()
-                }
+            if (broadcastStatus == 0){
+                gameListModelLiveData.value = ApiManager.roomApi.getHouseGameList()
+                roomConfigLiveData.value = ApiManager.roomApi.getHouseRoomConfig()
+                recommendGameListModelLiveData.value = ApiManager.roomApi.getHouseRecommendGameList()
+            } else {
+                gameListModelLiveData.value = ApiManager.roomApi.getGameList()
+                roomConfigLiveData.value = ApiManager.roomApi.getRoomConfig()
+                recommendGameListModelLiveData.value = ApiManager.roomApi.getRecommendGameList()
             }
 
         }

+ 3 - 13
room/src/main/java/com/swago/room/widget/AnchorFooterView.kt

@@ -29,14 +29,13 @@ class AnchorFooterView : ConstraintLayout, IFooter, IRoomActiveListener {
     lateinit var binding: LayoutAnchorFooterViewBinding
 
     var openSendMsgDialog:(()->Unit)? = null
-    var openMessageFun:(()->Unit)? = null
+    var openMoreDialog:(()->Unit)? = null
     var openGameFun:(()->Unit)? = null
     var openPKFun:(()->Unit)? = null
     var openLianMaiFun:(()->Unit)? = null
     var clearJiFen:(()->Unit)? = null
     var openAudioNoticeDialogFun:(()->Unit)? = null
     var openGiftPanelFun:(()->Unit)? = null
-    var openShareFun:(()->Unit)? = null
     var isMute = false
 
     constructor(context: Context) : this(context, null)
@@ -73,12 +72,6 @@ class AnchorFooterView : ConstraintLayout, IFooter, IRoomActiveListener {
             }
         })
 
-        binding.ivMessage.setOnClickListener(object : NoDoubleClickListener() {
-            override fun onClick() {
-                openMessageFun?.invoke()
-            }
-        })
-
         binding.ivGame.setOnClickListener(object : NoDoubleClickListener() {
             override fun onClick() {
                 openGameFun?.invoke()
@@ -137,9 +130,9 @@ class AnchorFooterView : ConstraintLayout, IFooter, IRoomActiveListener {
             }
         })
 
-        binding.ivShare.setOnClickListener(object : NoDoubleClickListener() {
+        binding.ivMore.setOnClickListener(object : NoDoubleClickListener(){
             override fun onClick() {
-                openShareFun?.invoke()
+                openMoreDialog?.invoke()
             }
         })
     }
@@ -169,9 +162,6 @@ class AnchorFooterView : ConstraintLayout, IFooter, IRoomActiveListener {
             binding.ivClearJifen.visibility = View.VISIBLE
             binding.ivNotice.visibility = View.VISIBLE
             binding.ivGift.visibility = View.VISIBLE
-            binding.ivShare.visibility = View.GONE
-        }else if(iRoomInfo.getRoomType() == RoomType.VIDEO.type){
-            binding.ivShare.visibility = View.VISIBLE
         }
         visibility = View.VISIBLE
     }

+ 39 - 0
room/src/main/res/layout/dialog_footer_more.xml

@@ -0,0 +1,39 @@
+<?xml version="1.0" encoding="utf-8"?>
+<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
+    xmlns:app="http://schemas.android.com/apk/res-auto"
+    android:layout_width="match_parent"
+    android:layout_height="match_parent">
+
+    <androidx.constraintlayout.widget.ConstraintLayout
+        app:layout_constraintDimensionRatio="h,360:124"
+        android:background="@drawable/shape_white_top_20"
+        app:layout_constraintTop_toTopOf="parent"
+        android:layout_width="match_parent"
+        android:layout_height="0dp">
+
+    <ImageView
+        android:id="@+id/ivMessage"
+        android:layout_marginStart="10dp"
+        android:background="@drawable/shape_80000000_20"
+        app:layout_constraintTop_toTopOf="parent"
+        app:layout_constraintStart_toStartOf="parent"
+        android:src="@mipmap/live_message"
+        android:layout_marginTop="@dimen/dp_10"
+        android:layout_width="40dp"
+        android:layout_height="40dp"/>
+
+    <ImageView
+        android:id="@+id/ivShare"
+        android:layout_marginStart="16dp"
+        android:background="@drawable/shape_80000000_20"
+        app:layout_constraintTop_toTopOf="parent"
+        app:layout_constraintStart_toEndOf="@+id/ivMessage"
+        android:src="@mipmap/live_share"
+        android:padding="6dp"
+        android:layout_marginTop="@dimen/dp_10"
+        android:layout_width="40dp"
+        android:layout_height="40dp"/>
+
+    </androidx.constraintlayout.widget.ConstraintLayout>
+
+</androidx.constraintlayout.widget.ConstraintLayout>

+ 4 - 17
room/src/main/res/layout/layout_anchor_footer_view.xml

@@ -74,20 +74,6 @@
         android:layout_height="10dp"/>
 
 
-    <ImageView
-        android:id="@+id/ivShare"
-        android:layout_marginStart="10dp"
-        app:layout_constraintTop_toTopOf="parent"
-        app:layout_constraintStart_toEndOf="@+id/ivLianMai"
-        android:background="@drawable/shape_80000000_20"
-        android:src="@mipmap/live_share"
-        android:padding="7dp"
-        android:visibility="gone"
-        tools:visibility="visible"
-        android:layout_width="40dp"
-        android:layout_height="40dp"/>
-
-
     <ImageView
         android:id="@+id/ivGift"
         android:layout_marginStart="10dp"
@@ -132,14 +118,16 @@
         android:layout_marginEnd="10dp"
         android:background="@drawable/shape_80000000_20"
         app:layout_constraintTop_toTopOf="parent"
-        app:layout_constraintEnd_toStartOf="@+id/ivMessage"
+        app:layout_constraintEnd_toStartOf="@+id/ivMore"
         android:src="@mipmap/live_unmute"
         android:padding="7dp"
         android:layout_width="40dp"
         android:layout_height="40dp"/>
 
+
+
     <ImageView
-        android:id="@+id/ivMessage"
+        android:id="@+id/ivMore"
         android:layout_marginEnd="10dp"
         android:background="@drawable/shape_80000000_20"
         app:layout_constraintTop_toTopOf="parent"
@@ -148,5 +136,4 @@
         android:layout_width="40dp"
         android:layout_height="40dp"/>
 
-
 </androidx.constraintlayout.widget.ConstraintLayout>

+ 0 - 2
room/src/main/res/layout/view_user_join_room.xml

@@ -97,7 +97,6 @@
             <TextView
                 android:id="@+id/tvName"
                 app:layout_constraintStart_toEndOf="@+id/swagoLevel"
-                app:layout_constraintEnd_toEndOf="parent"
                 app:layout_constraintTop_toTopOf="@+id/ivAvatar"
                 android:layout_marginStart="5dp"
                 android:layout_marginEnd="20dp"
@@ -111,7 +110,6 @@
 
             <TextView
                 android:id="@+id/tvJoin"
-                app:layout_constraintEnd_toEndOf="parent"
                 app:layout_constraintStart_toEndOf="@+id/ivAvatar"
                 app:layout_constraintBottom_toBottomOf="@+id/ivAvatar"
                 android:layout_marginEnd="20dp"