From 2e700d438565aedfedc196273b7affbcd153bb73 Mon Sep 17 00:00:00 2001 From: klaus Date: Thu, 5 Mar 2026 11:01:26 +0900 Subject: [PATCH] =?UTF-8?q?fix(live-room):=20=EB=9D=BC=EC=9D=B4=EB=B8=8C?= =?UTF-8?q?=20=EB=A3=B8=20=ED=8C=94=EB=A1=9C=EC=9A=B0=20=EB=B2=84=ED=8A=BC?= =?UTF-8?q?=20=EC=95=8C=EB=A6=BC=20=EC=83=81=ED=83=9C=EB=A5=BC=20=EB=B0=98?= =?UTF-8?q?=EC=98=81=ED=95=9C=EB=8B=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../vividnext/sodalive/live/LiveRepository.kt | 6 +- .../sodalive/live/room/LiveRoomActivity.kt | 95 +++++++++++++++++-- .../sodalive/live/room/LiveRoomViewModel.kt | 12 ++- .../main/res/layout/activity_live_room.xml | 9 ++ docs/20260305_라이브룸팔로우버튼추가.md | 14 +++ 5 files changed, 126 insertions(+), 10 deletions(-) create mode 100644 docs/20260305_라이브룸팔로우버튼추가.md diff --git a/app/src/main/java/kr/co/vividnext/sodalive/live/LiveRepository.kt b/app/src/main/java/kr/co/vividnext/sodalive/live/LiveRepository.kt index d6a61386..40bc2645 100644 --- a/app/src/main/java/kr/co/vividnext/sodalive/live/LiveRepository.kt +++ b/app/src/main/java/kr/co/vividnext/sodalive/live/LiveRepository.kt @@ -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 ) diff --git a/app/src/main/java/kr/co/vividnext/sodalive/live/room/LiveRoomActivity.kt b/app/src/main/java/kr/co/vividnext/sodalive/live/room/LiveRoomActivity.kt index 0518ca2d..a75fd55d 100644 --- a/app/src/main/java/kr/co/vividnext/sodalive/live/room/LiveRoomActivity.kt +++ b/app/src/main/java/kr/co/vividnext/sodalive/live/room/LiveRoomActivity.kt @@ -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(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(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(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) diff --git a/app/src/main/java/kr/co/vividnext/sodalive/live/room/LiveRoomViewModel.kt b/app/src/main/java/kr/co/vividnext/sodalive/live/room/LiveRoomViewModel.kt index cb3ad73a..b84397be 100644 --- a/app/src/main/java/kr/co/vividnext/sodalive/live/room/LiveRoomViewModel.kt +++ b/app/src/main/java/kr/co/vividnext/sodalive/live/room/LiveRoomViewModel.kt @@ -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()) diff --git a/app/src/main/res/layout/activity_live_room.xml b/app/src/main/res/layout/activity_live_room.xml index 06f83812..bff2a110 100644 --- a/app/src/main/res/layout/activity_live_room.xml +++ b/app/src/main/res/layout/activity_live_room.xml @@ -526,6 +526,15 @@ tools:text="999,999" /> + +