|
|
@@ -1,27 +1,56 @@
|
|
|
package com.adealink.weparty.room.chatroom.page.dispatchcenter
|
|
|
|
|
|
+import android.annotation.SuppressLint
|
|
|
import com.adealink.frame.mvvm.view.viewBinding
|
|
|
import com.adealink.weparty.commonui.BaseFragment
|
|
|
-import com.adealink.weparty.module.profile.ProfileModule
|
|
|
+import com.adealink.weparty.commonui.ext.gone
|
|
|
+import com.adealink.weparty.commonui.ext.show
|
|
|
import com.adealink.weparty.room.R
|
|
|
import com.adealink.weparty.room.databinding.FragmentDispatchCenterRoomInfoBinding
|
|
|
import com.adealink.weparty.room.sdk.service.roomService
|
|
|
+import io.trtc.tuikit.atomicxcore.api.live.LiveInfo
|
|
|
+import io.trtc.tuikit.atomicxcore.api.live.LiveListStore
|
|
|
+import kotlinx.coroutines.CoroutineScope
|
|
|
+import kotlinx.coroutines.Dispatchers
|
|
|
+import kotlinx.coroutines.Job
|
|
|
+import kotlinx.coroutines.launch
|
|
|
|
|
|
class DispatchCenterRoomInfoFragment : BaseFragment(R.layout.fragment_dispatch_center_room_info) {
|
|
|
|
|
|
private val binding by viewBinding(FragmentDispatchCenterRoomInfoBinding::bind)
|
|
|
|
|
|
+ private var subscribeStateJob: Job? = null
|
|
|
+
|
|
|
override fun initViews() {
|
|
|
- // TODO: zhangfei
|
|
|
- val userInfo = ProfileModule.getMyUserInfo()
|
|
|
- binding.roomCover.setImageUrl(userInfo?.avatar)
|
|
|
- binding.roomName.text = userInfo?.nickName
|
|
|
- binding.roomId.text = "ID ${roomService.joinController.getJoinedRoomId()}"
|
|
|
+ updateRoomInfo(roomService.joinController.joinedRoomInfo)
|
|
|
}
|
|
|
|
|
|
override fun observeViewModel() {
|
|
|
super.observeViewModel()
|
|
|
+ subscribeStateJob = CoroutineScope(Dispatchers.Main).launch {
|
|
|
+ LiveListStore.shared().liveState.currentLive.collect { liveInfo ->
|
|
|
+ if (liveInfo.liveID == roomService.joinController.getJoinedRoomId()) {
|
|
|
+ updateRoomInfo(liveInfo)
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ @SuppressLint("SetTextI18n")
|
|
|
+ private fun updateRoomInfo(liveInfo: LiveInfo?) {
|
|
|
+ binding.roomCover.setImageUrl(liveInfo?.coverURL)
|
|
|
+ binding.roomName.text = liveInfo?.liveName
|
|
|
+ liveInfo?.liveID?.let { liveID ->
|
|
|
+ binding.roomId.show()
|
|
|
+ binding.roomId.text = "ID $liveID"
|
|
|
+ } ?: let {
|
|
|
+ binding.roomId.gone()
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
+ override fun onDestroyView() {
|
|
|
+ super.onDestroyView()
|
|
|
+ subscribeStateJob?.cancel()
|
|
|
+ }
|
|
|
|
|
|
}
|