|
|
@@ -3,17 +3,17 @@ package com.adealink.weparty.profile.comp
|
|
|
import android.graphics.Outline
|
|
|
import android.view.View
|
|
|
import android.view.ViewOutlineProvider
|
|
|
-import androidx.constraintlayout.widget.ConstraintLayout
|
|
|
-import androidx.core.view.updateLayoutParams
|
|
|
import androidx.lifecycle.LifecycleOwner
|
|
|
-import com.adealink.frame.aab.util.getCompatDimension
|
|
|
+import com.adealink.frame.mvvm.viewmodel.viewModels
|
|
|
import com.adealink.frame.util.onClick
|
|
|
-import com.adealink.weparty.R
|
|
|
import com.adealink.weparty.commonui.BaseActivity
|
|
|
+import com.adealink.weparty.commonui.ext.gone
|
|
|
import com.adealink.weparty.commonui.ext.show
|
|
|
import com.adealink.weparty.module.room.RoomModule
|
|
|
+import com.adealink.weparty.module.room.data.RoomInfo
|
|
|
import com.adealink.weparty.profile.databinding.LayoutUserProfileHeaderBinding
|
|
|
import com.adealink.weparty.profile.databinding.LayoutUserProfileRoomOnlineBinding
|
|
|
+import com.adealink.weparty.profile.viewmodel.ProfileRoomViewModel
|
|
|
|
|
|
class ProfileRoomStatusComp(
|
|
|
lifecycleOwner: LifecycleOwner,
|
|
|
@@ -22,11 +22,11 @@ class ProfileRoomStatusComp(
|
|
|
private val binding: LayoutUserProfileRoomOnlineBinding,
|
|
|
) : BaseProfileViewComp(lifecycleOwner, userUid) {
|
|
|
|
|
|
+ private val roomViewModel by viewModels<ProfileRoomViewModel>()
|
|
|
+
|
|
|
override fun initView() {
|
|
|
initBlur()
|
|
|
-
|
|
|
- // TODO: zhangfei
|
|
|
- binding.root.show()
|
|
|
+ binding.root.gone()
|
|
|
binding.root.onClick {
|
|
|
val act = (activity as? BaseActivity) ?: return@onClick
|
|
|
RoomModule.createRoom(act)
|
|
|
@@ -42,10 +42,6 @@ class ProfileRoomStatusComp(
|
|
|
outline.alpha = 1f
|
|
|
}
|
|
|
}
|
|
|
-// val radius = 25f
|
|
|
-// val minBlurRadius = 4f
|
|
|
-// val step = 4f
|
|
|
- //set background, if your root layout doesn't have one
|
|
|
val windowBackground = activity?.window?.decorView?.background
|
|
|
headerBinding.vRoomOnlineBlurBar.setupWith(headerBinding.ivBgBlurTarget)
|
|
|
.setFrameClearDrawable(windowBackground)
|
|
|
@@ -53,9 +49,28 @@ class ProfileRoomStatusComp(
|
|
|
}
|
|
|
|
|
|
override fun observeViewModel() {
|
|
|
- profileViewModel.userInfoLD.observe(viewLifecycleOwner) {
|
|
|
- updateUI(it)
|
|
|
+ roomViewModel.userRoomInfoLD.observe(viewLifecycleOwner) {
|
|
|
+ if (it.first == userUid) {
|
|
|
+ val roomInfo = it.second
|
|
|
+ updateRoomInfo(roomInfo)
|
|
|
+ } else {
|
|
|
+ updateRoomInfo(null)
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ private fun updateRoomInfo(roomInfo: RoomInfo?) {
|
|
|
+ if (roomInfo == null || roomInfo.roomId.isNullOrEmpty()) {
|
|
|
+ binding.root.gone()
|
|
|
+ return
|
|
|
}
|
|
|
+ binding.root.show()
|
|
|
+ binding.ivCover.setImageUrl(roomInfo.roomCover)
|
|
|
+ }
|
|
|
+
|
|
|
+ override fun loadData() {
|
|
|
+ super.loadData()
|
|
|
+ roomViewModel.getUserRoomStatus(userUid)
|
|
|
}
|
|
|
|
|
|
|