Bläddra i källkod

连线跳对面

jlin 4 veckor sedan
förälder
incheckning
26fb26940d

+ 43 - 1
module_live/src/main/java/com/yc/module_live/view/live/livetop/TopLiveLayerFragment.kt

@@ -22,17 +22,21 @@ import com.xueyu.kotlinextlibrary.toGone
 import com.xueyu.kotlinextlibrary.toInVisible
 import com.xueyu.kotlinextlibrary.toVisible
 import com.yc.baselibrary.adapter.viewHolder.MutableAdapter
+import com.yc.baselibrary.coroutines.lazyRetrofit
 import com.yc.baselibrary.event.LiveBusEvent
 import com.yc.baselibrary.ext.bind
 import com.yc.baselibrary.ext.countDownCoroutines
 import com.yc.baselibrary.ext.loadImage
 import com.yc.baselibrary.ext.scrollStateChanged
+import com.yc.baselibrary.ext.setSafeListener
 import com.yc.baselibrary.ext.toast
 import com.yc.baselibrary.utils.ComponentUtil
 import com.yc.baselibrary.utils.NumString
 import com.yc.baselibrary.view.isBottom2
 import com.yc.module_base.LiveSession
+import com.yc.module_base.api.CommonService
 import com.yc.module_base.ext.userId
+import com.yc.module_base.manager.AddressHelper.requestMix
 import com.yc.module_base.manager.GiftManager
 import com.yc.module_base.model.Barrage
 import com.yc.module_base.model.BarrageType
@@ -49,7 +53,9 @@ import com.yc.module_base.model.PKHeat
 import com.yc.module_base.model.PKResult
 import com.yc.module_base.model.PKTimeData
 import com.yc.module_base.model.PKUserRank
+import com.yc.module_base.model.PostUserCardBody
 import com.yc.module_base.model.Room
+import com.yc.module_base.model.RoomModelType
 import com.yc.module_base.model.ShareInfo
 import com.yc.module_base.model.StartPKData
 import com.yc.module_base.model.User
@@ -83,6 +89,8 @@ import com.yc.module_live.view.toplayer.cell.RoomUserFollowAnchorVH
 import com.yc.module_live.view.toplayer.cell.RoomUserLeaveRoomVH
 import com.yc.module_live.view.toplayer.cell.RoomUserVH
 import com.yc.module_live.widget.GiftChannelLayout
+import kotlinx.android.synthetic.main.module_room_pk_anchor_layout.view.pkRight
+import kotlinx.android.synthetic.main.module_room_pk_anchor_layout.view.pkTarInfo
 import kotlinx.android.synthetic.main.module_room_top_live_layer_fragment.bigGiftView
 import kotlinx.android.synthetic.main.module_room_top_live_layer_fragment.blindBoxGiftView
 import kotlinx.android.synthetic.main.module_room_top_live_layer_fragment.carView
@@ -95,6 +103,7 @@ import kotlinx.android.synthetic.main.module_room_top_live_layer_fragment.ivTarg
 import kotlinx.android.synthetic.main.module_room_top_live_layer_fragment.ivVoice
 import kotlinx.android.synthetic.main.module_room_top_live_layer_fragment.layoutBottom
 import kotlinx.android.synthetic.main.module_room_top_live_layer_fragment.linkClose
+import kotlinx.android.synthetic.main.module_room_top_live_layer_fragment.linkRight
 import kotlinx.android.synthetic.main.module_room_top_live_layer_fragment.linkTarInfo
 import kotlinx.android.synthetic.main.module_room_top_live_layer_fragment.multipleChannelView
 import kotlinx.android.synthetic.main.module_room_top_live_layer_fragment.multiplePreview
@@ -124,7 +133,7 @@ class TopLiveLayerFragment : TopLiveLayerClickFragment<TopLayerVm>(),
         val liveRoom = arguments?.getParcelable<Room>(BaseRoomVm.ROOM_INFO)
         setValue(BaseRoomVm.ROOM_INFO to liveRoom)
     }
-
+    private val retrofit: CommonService by lazyRetrofit()
     private var layoutManager: LinearLayoutManager? = null
     private var itemCount = 0
     private var lastPosition: Int = 0
@@ -1167,6 +1176,39 @@ class TopLiveLayerFragment : TopLiveLayerClickFragment<TopLayerVm>(),
             linkTarInfo.setOnClickListener {
                 showUserCardDialog(user, 1)
             }
+
+            linkRight.setSafeListener {
+                showDialogSample(
+                    "确定跳转对方直播间吗?"
+                ) {
+                    confirmText("确定")
+                    confirm {
+                        if (viewModel.room?.isLiving == true && viewModel.room?.anchor?.userId == userId) {
+                            toast("正在直播中,无法切换房间")
+                        } else if (viewModel.room?.roomId == viewModel.room?.anchor?.userId) {
+                            toast("已在本房间")
+                        } else {
+                            viewModel.getUnReadMessage()
+                            requestMix({
+                                retrofit.getUserCardInfo(PostUserCardBody(viewModel.tarPkUser?.userId?:0L))
+                            }) {
+                                success {
+                                    it.data.let { user->
+                                        (activity as RoomActivity).switchRoom(
+                                            Room(
+                                                roomId = user.roomInfo?.roomId ?: 0L,
+                                                roomPic = user.picture,
+                                                roomModel = RoomModelType.LIVE.type
+                                            )
+                                        )
+                                    }
+                                }
+
+                            }
+                        }
+                    }
+                }
+            }
         }
         tvLiveLianxian.toVisible()
     }

+ 1 - 1
module_live/src/main/java/com/yc/module_live/view/video/VideoFragment.kt

@@ -225,7 +225,7 @@ class VideoFragment : BaseFragment<VideoVm>() {
     }
 
     fun stopMicList() {
-        if (viewModel.room?.micList?.size == 0) {
+        if (viewModel.room?.micList == null ||viewModel.room?.micList?.size == 0) {
             return
         }
         for (i in viewModel.room?.micList?.indices!!) {