fix(live-room): 라이브 룸 팔로우 버튼 알림 상태를 반영한다
This commit is contained in:
@@ -200,9 +200,13 @@ class LiveRepository(
|
||||
|
||||
fun creatorFollow(
|
||||
creatorId: Long,
|
||||
notify: Boolean = true,
|
||||
token: String
|
||||
) = userApi.creatorFollow(
|
||||
request = CreatorFollowRequestRequest(creatorId = creatorId),
|
||||
request = CreatorFollowRequestRequest(
|
||||
creatorId = creatorId,
|
||||
isNotify = notify
|
||||
),
|
||||
authHeader = token
|
||||
)
|
||||
|
||||
|
||||
@@ -84,6 +84,7 @@ import kr.co.vividnext.sodalive.common.SharedPreferenceManager
|
||||
import kr.co.vividnext.sodalive.common.SodaLiveService
|
||||
import kr.co.vividnext.sodalive.databinding.ActivityLiveRoomBinding
|
||||
import kr.co.vividnext.sodalive.dialog.LiveDialog
|
||||
import kr.co.vividnext.sodalive.explorer.profile.CreatorFollowNotifyFragment
|
||||
import kr.co.vividnext.sodalive.extensions.dpToPx
|
||||
import kr.co.vividnext.sodalive.extensions.loadUrl
|
||||
import kr.co.vividnext.sodalive.extensions.moneyFormat
|
||||
@@ -156,6 +157,7 @@ class LiveRoomActivity : BaseActivity<ActivityLiveRoomBinding>(ActivityLiveRoomB
|
||||
private var isAvailableLikeHeart = false
|
||||
private var buttonPosition = IntArray(2)
|
||||
private var isEntryMessageEnabled = true
|
||||
private var isCreatorFollowNotifyEnabled = true
|
||||
|
||||
// joinChannel 중복 호출 방지 플래그
|
||||
private var hasInvokedJoinChannel = false
|
||||
@@ -694,6 +696,92 @@ class LiveRoomActivity : BaseActivity<ActivityLiveRoomBinding>(ActivityLiveRoomB
|
||||
}
|
||||
}
|
||||
|
||||
private fun bindCreatorFollowButton(response: GetRoomInfoResponse) {
|
||||
val isMyRoom = response.creatorId == SharedPreferenceManager.userId
|
||||
|
||||
if (isMyRoom) {
|
||||
binding.ivCreatorFollow.visibility = View.GONE
|
||||
binding.ivCreatorFollow.setOnClickListener(null)
|
||||
binding.llViewUsers.visibility = View.VISIBLE
|
||||
binding.llViewUsers.setOnClickListener { roomProfileDialog.show() }
|
||||
isCreatorFollowNotifyEnabled = true
|
||||
return
|
||||
}
|
||||
|
||||
binding.llViewUsers.visibility = View.GONE
|
||||
binding.llViewUsers.setOnClickListener(null)
|
||||
binding.ivCreatorFollow.visibility = View.VISIBLE
|
||||
|
||||
if (!response.isFollowing) {
|
||||
isCreatorFollowNotifyEnabled = true
|
||||
}
|
||||
|
||||
binding.ivCreatorFollow.setImageResource(
|
||||
if (response.isFollowing) {
|
||||
if (isCreatorFollowNotifyEnabled) {
|
||||
R.drawable.btn_following_big
|
||||
} else {
|
||||
R.drawable.btn_following_no_alarm_big
|
||||
}
|
||||
} else {
|
||||
R.drawable.btn_follow_big
|
||||
}
|
||||
)
|
||||
|
||||
binding.ivCreatorFollow.setOnClickListener {
|
||||
if (response.isFollowing) {
|
||||
showCreatorFollowNotifyDialog(response.creatorId)
|
||||
} else {
|
||||
isCreatorFollowNotifyEnabled = true
|
||||
viewModel.creatorFollow(
|
||||
creatorId = response.creatorId,
|
||||
roomId = roomId
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private fun showCreatorFollowNotifyDialog(creatorId: Long) {
|
||||
if (
|
||||
supportFragmentManager.findFragmentByTag(
|
||||
CreatorFollowNotifyFragment::class.java.simpleName
|
||||
) != null
|
||||
) {
|
||||
return
|
||||
}
|
||||
|
||||
val notifyFragment = CreatorFollowNotifyFragment(
|
||||
onClickNotifyAll = {
|
||||
isCreatorFollowNotifyEnabled = true
|
||||
viewModel.creatorFollow(
|
||||
creatorId = creatorId,
|
||||
roomId = roomId,
|
||||
notify = true
|
||||
)
|
||||
},
|
||||
onClickNotifyNone = {
|
||||
isCreatorFollowNotifyEnabled = false
|
||||
viewModel.creatorFollow(
|
||||
creatorId = creatorId,
|
||||
roomId = roomId,
|
||||
notify = false
|
||||
)
|
||||
},
|
||||
onClickUnFollow = {
|
||||
isCreatorFollowNotifyEnabled = true
|
||||
viewModel.creatorUnFollow(
|
||||
creatorId = creatorId,
|
||||
roomId = roomId
|
||||
)
|
||||
}
|
||||
)
|
||||
|
||||
notifyFragment.show(
|
||||
supportFragmentManager,
|
||||
CreatorFollowNotifyFragment::class.java.simpleName
|
||||
)
|
||||
}
|
||||
|
||||
@SuppressLint("SetTextI18n")
|
||||
private fun bindData() {
|
||||
viewModel.isBgOn.observe(this) {
|
||||
@@ -958,12 +1046,7 @@ class LiveRoomActivity : BaseActivity<ActivityLiveRoomBinding>(ActivityLiveRoomB
|
||||
}
|
||||
}
|
||||
|
||||
if (response.creatorId == SharedPreferenceManager.userId) {
|
||||
binding.llViewUsers.visibility = View.VISIBLE
|
||||
binding.llViewUsers.setOnClickListener { roomProfileDialog.show() }
|
||||
} else {
|
||||
binding.llViewUsers.visibility = View.GONE
|
||||
}
|
||||
bindCreatorFollowButton(response)
|
||||
|
||||
binding.tvParticipate.text = "${response.participantsCount}"
|
||||
setNoticeAndClickableUrl(binding.tvNotice, response.notice)
|
||||
|
||||
@@ -432,12 +432,18 @@ class LiveRoomViewModel(
|
||||
onSuccess(message)
|
||||
}
|
||||
|
||||
fun creatorFollow(creatorId: Long, roomId: Long, isGetUserProfile: Boolean = false) {
|
||||
fun creatorFollow(
|
||||
creatorId: Long,
|
||||
roomId: Long,
|
||||
notify: Boolean = true,
|
||||
isGetUserProfile: Boolean = false
|
||||
) {
|
||||
_isLoading.value = true
|
||||
compositeDisposable.add(
|
||||
repository.creatorFollow(
|
||||
creatorId,
|
||||
"Bearer ${SharedPreferenceManager.token}"
|
||||
creatorId = creatorId,
|
||||
notify = notify,
|
||||
token = "Bearer ${SharedPreferenceManager.token}"
|
||||
)
|
||||
.subscribeOn(Schedulers.io())
|
||||
.observeOn(AndroidSchedulers.mainThread())
|
||||
|
||||
@@ -526,6 +526,15 @@
|
||||
tools:text="999,999" />
|
||||
</LinearLayout>
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/iv_creator_follow"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginStart="5.3dp"
|
||||
android:contentDescription="@null"
|
||||
android:visibility="gone"
|
||||
tools:src="@drawable/btn_follow_big" />
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/ll_view_users"
|
||||
android:layout_width="wrap_content"
|
||||
|
||||
Reference in New Issue
Block a user