refactor(home): 홈 접근 가드를 공통화한다

This commit is contained in:
2026-07-14 20:44:42 +09:00
parent d5d3444c3a
commit 7e12aa8720
3 changed files with 34 additions and 33 deletions
@@ -7,7 +7,6 @@ import androidx.recyclerview.widget.LinearLayoutManager
import kr.co.vividnext.sodalive.R
import kr.co.vividnext.sodalive.base.BaseFragment
import kr.co.vividnext.sodalive.common.LoadingDialog
import kr.co.vividnext.sodalive.common.SharedPreferenceManager
import kr.co.vividnext.sodalive.common.ToastMessage
import kr.co.vividnext.sodalive.common.formatUtcRelativeTimeText
import kr.co.vividnext.sodalive.databinding.FragmentV2MainHomeBinding
@@ -25,7 +24,8 @@ import kr.co.vividnext.sodalive.v2.live.onair.HomeOnAirLiveActivity
import kr.co.vividnext.sodalive.v2.main.chat.dm.DmChatRoomActivity
import kr.co.vividnext.sodalive.v2.main.chat.model.ChatRoomListUiItem
import kr.co.vividnext.sodalive.v2.main.chat.model.ChatRoomType
import kr.co.vividnext.sodalive.v2.main.ensureMainV2NavigationAllowed
import kr.co.vividnext.sodalive.v2.access.AccessRequirement
import kr.co.vividnext.sodalive.v2.access.ensureV2Access
import kr.co.vividnext.sodalive.v2.main.home.model.HomeFollowingChatSection
import kr.co.vividnext.sodalive.v2.main.home.model.HomeFollowingCreatorSection
import kr.co.vividnext.sodalive.v2.main.home.model.HomeFollowingLiveSection
@@ -166,7 +166,7 @@ class HomeMainFragment : BaseFragment<FragmentV2MainHomeBinding>(
}
private fun openWithLoginGuard(activityClass: Class<*>) {
ensureMainV2NavigationAllowed {
ensureV2Access(AccessRequirement.Login) {
startActivity(Intent(requireContext(), activityClass))
}
}
@@ -270,12 +270,13 @@ class HomeMainFragment : BaseFragment<FragmentV2MainHomeBinding>(
}
private fun openFollowingTab() {
if (SharedPreferenceManager.token.isBlank()) {
val allowed = ensureV2Access(AccessRequirement.Login)
if (!allowed) {
binding.textTabBarHome.root.selectTab(currentHomeTabIndex)
return
}
ensureMainV2NavigationAllowed {
showHomeTab(HOME_TAB_FOLLOWING)
}
showHomeTab(HOME_TAB_FOLLOWING)
}
private fun showHomeTab(index: Int) {
@@ -532,10 +533,10 @@ class HomeMainFragment : BaseFragment<FragmentV2MainHomeBinding>(
}
private fun onLiveClick(item: HomeRecommendationLiveUiModel) {
ensureMainV2NavigationAllowed {
ensureV2Access(AccessRequirement.Login) {
liveViewModel.getRoomDetail(item.roomId) { roomDetail ->
if (!isAdded || view == null) return@getRoomDetail
ensureMainV2NavigationAllowed(requiresAdultContentAccess = roomDetail.isAdult) {
ensureV2Access(AccessRequirement.forAdultContent(roomDetail.isAdult)) {
liveCoordinator.enterLiveRoom(item.roomId, roomDetail)
}
}
@@ -543,7 +544,7 @@ class HomeMainFragment : BaseFragment<FragmentV2MainHomeBinding>(
}
private fun openHomeOnAirLive() {
ensureMainV2NavigationAllowed {
ensureV2Access(AccessRequirement.Login) {
startActivity(HomeOnAirLiveActivity.newIntent(requireContext()))
}
}
@@ -558,19 +559,19 @@ class HomeMainFragment : BaseFragment<FragmentV2MainHomeBinding>(
val community = item as? HomeFollowingNewsUiItem.Community ?: return
val postId = community.postId
if (postId <= 0L) return
ensureMainV2NavigationAllowed {
ensureV2Access(AccessRequirement.Login) {
startActivity(CreatorChannelCommunityDetailActivity.newIntent(requireContext(), postId))
}
}
private fun openFollowingCreatorAll() {
ensureMainV2NavigationAllowed {
ensureV2Access(AccessRequirement.Login) {
startActivity(Intent(requireContext(), FollowingCreatorActivity::class.java))
}
}
private fun openFollowingChat(item: ChatRoomListUiItem) {
ensureMainV2NavigationAllowed {
ensureV2Access(AccessRequirement.Login) {
when (item.chatType) {
ChatRoomType.AI -> startActivity(ChatRoomActivity.newIntent(requireContext(), item.roomId))
ChatRoomType.DM -> startActivity(DmChatRoomActivity.newIntentByRoomId(requireContext(), item.roomId))
@@ -580,21 +581,21 @@ class HomeMainFragment : BaseFragment<FragmentV2MainHomeBinding>(
private fun onBannerClick(item: HomeRecommendationBannerUiModel) {
val route = item.toHomeRecommendationBannerRoute() ?: return
ensureMainV2NavigationAllowed {
ensureV2Access(AccessRequirement.Login) {
startActivity(route.toHomeRecommendationBannerIntent(requireContext()))
}
}
private fun onRecentActivityClick(item: HomeRecommendationRecentlyActiveCreatorUiModel) {
val route = item.toHomeRecommendationRecentlyActiveCreatorRoute() ?: return
ensureMainV2NavigationAllowed {
ensureV2Access(AccessRequirement.Login) {
startActivity(route.toHomeRecommendationRecentlyActiveCreatorIntent(requireContext()))
}
}
private fun onAiCharacterClick(item: HomeRecommendationAiCharacterUiModel) {
val route = item.toHomeRecommendationAiCharacterRoute() ?: return
ensureMainV2NavigationAllowed {
ensureV2Access(AccessRequirement.Login) {
startActivity(route.toHomeRecommendationAiCharacterIntent(requireContext()))
}
}
@@ -605,7 +606,7 @@ class HomeMainFragment : BaseFragment<FragmentV2MainHomeBinding>(
}
private fun openCreatorProfile(creatorId: Long) {
ensureMainV2NavigationAllowed {
ensureV2Access(AccessRequirement.Login) {
startActivity(
CreatorChannelActivity.newIntent(requireContext(), creatorId)
)
@@ -614,7 +615,7 @@ class HomeMainFragment : BaseFragment<FragmentV2MainHomeBinding>(
private fun openPopularCommunityPost(item: FeedItem.Community) {
val postId = item.postId.toLongOrNull() ?: return
ensureMainV2NavigationAllowed {
ensureV2Access(AccessRequirement.Login) {
startActivity(CreatorChannelCommunityDetailActivity.newIntent(requireContext(), postId))
}
}