feat(home): 팔로잉 탭 로그인 가드를 보강한다

This commit is contained in:
2026-06-27 03:54:21 +09:00
parent 39dd003b4e
commit a0cfa70551
2 changed files with 173 additions and 23 deletions

View File

@@ -9,6 +9,7 @@ import kr.co.vividnext.sodalive.audio_content.detail.AudioContentDetailActivity
import kr.co.vividnext.sodalive.base.BaseFragment
import kr.co.vividnext.sodalive.common.Constants
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
@@ -20,6 +21,7 @@ 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.main.home.model.HomeFollowingChatSection
import kr.co.vividnext.sodalive.v2.main.home.model.HomeFollowingCreatorSection
import kr.co.vividnext.sodalive.v2.main.home.model.HomeFollowingLiveSection
@@ -106,6 +108,7 @@ class HomeMainFragment : BaseFragment<FragmentV2MainHomeBinding>(
private var onCheerFollowAllClick: (List<Long>) -> Unit = {}
private var hasLoadedCreatorRankings = false
private var hasLoadedFollowing = false
private var currentHomeTabIndex = HOME_TAB_RECOMMENDATION
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
super.onViewCreated(view, savedInstanceState)
@@ -118,7 +121,11 @@ class HomeMainFragment : BaseFragment<FragmentV2MainHomeBinding>(
selectedIndex = 0
)
binding.textTabBarHome.root.setOnTabSelectedListener { index ->
showHomeTab(index)
when (index) {
HOME_TAB_FOLLOWING -> openFollowingTab()
else -> showHomeTab(index)
}
}
setUpSectionTitles()
setUpRecommendationAdapters()
@@ -233,7 +240,17 @@ class HomeMainFragment : BaseFragment<FragmentV2MainHomeBinding>(
}
}
private fun openFollowingTab() {
if (SharedPreferenceManager.token.isBlank()) {
binding.textTabBarHome.root.selectTab(currentHomeTabIndex)
}
ensureMainV2NavigationAllowed {
showHomeTab(HOME_TAB_FOLLOWING)
}
}
private fun showHomeTab(index: Int) {
currentHomeTabIndex = index
when (index) {
HOME_TAB_RECOMMENDATION -> {
binding.nsvHomeRecommendationContent.visibility = View.VISIBLE
@@ -487,7 +504,9 @@ class HomeMainFragment : BaseFragment<FragmentV2MainHomeBinding>(
private fun onLiveClick(item: HomeRecommendationLiveUiModel) = Unit
private fun openHomeOnAirLive() {
startActivity(HomeOnAirLiveActivity.newIntent(requireContext()))
ensureMainV2NavigationAllowed {
startActivity(HomeOnAirLiveActivity.newIntent(requireContext()))
}
}
private fun onFollowingSectionMoreClick(section: HomeFollowingSection) = Unit
@@ -499,25 +518,33 @@ class HomeMainFragment : BaseFragment<FragmentV2MainHomeBinding>(
private fun onFollowingNewsClick(item: HomeFollowingNewsUiItem) = Unit
private fun openFollowingChat(item: ChatRoomListUiItem) {
when (item.chatType) {
ChatRoomType.AI -> startActivity(ChatRoomActivity.newIntent(requireContext(), item.roomId))
ChatRoomType.DM -> startActivity(DmChatRoomActivity.newIntentByRoomId(requireContext(), item.roomId))
ensureMainV2NavigationAllowed {
when (item.chatType) {
ChatRoomType.AI -> startActivity(ChatRoomActivity.newIntent(requireContext(), item.roomId))
ChatRoomType.DM -> startActivity(DmChatRoomActivity.newIntentByRoomId(requireContext(), item.roomId))
}
}
}
private fun onBannerClick(item: HomeRecommendationBannerUiModel) {
val route = item.toHomeRecommendationBannerRoute() ?: return
startActivity(route.toHomeRecommendationBannerIntent(requireContext()))
ensureMainV2NavigationAllowed {
startActivity(route.toHomeRecommendationBannerIntent(requireContext()))
}
}
private fun onRecentActivityClick(item: HomeRecommendationRecentlyActiveCreatorUiModel) {
val route = item.toHomeRecommendationRecentlyActiveCreatorRoute() ?: return
startActivity(route.toHomeRecommendationRecentlyActiveCreatorIntent(requireContext()))
ensureMainV2NavigationAllowed {
startActivity(route.toHomeRecommendationRecentlyActiveCreatorIntent(requireContext()))
}
}
private fun onAiCharacterClick(item: HomeRecommendationAiCharacterUiModel) {
val route = item.toHomeRecommendationAiCharacterRoute() ?: return
startActivity(route.toHomeRecommendationAiCharacterIntent(requireContext()))
ensureMainV2NavigationAllowed {
startActivity(route.toHomeRecommendationAiCharacterIntent(requireContext()))
}
}
private fun openCreatorRankingProfile(item: CreatorRankingItem) {
@@ -526,29 +553,35 @@ class HomeMainFragment : BaseFragment<FragmentV2MainHomeBinding>(
}
private fun openCreatorProfile(creatorId: Long) {
startActivity(
CreatorChannelActivity.newIntent(requireContext(), creatorId)
)
ensureMainV2NavigationAllowed {
startActivity(
CreatorChannelActivity.newIntent(requireContext(), creatorId)
)
}
}
private fun openAudioContentDetail(item: HomeRecommendationFirstAudioContentUiModel) {
startActivity(
Intent(requireContext(), AudioContentDetailActivity::class.java).apply {
putExtra(Constants.EXTRA_AUDIO_CONTENT_ID, item.contentId)
}
)
ensureMainV2NavigationAllowed {
startActivity(
Intent(requireContext(), AudioContentDetailActivity::class.java).apply {
putExtra(Constants.EXTRA_AUDIO_CONTENT_ID, item.contentId)
}
)
}
}
private fun openPopularCommunityPost(item: FeedItem.Community) {
val creatorId = item.creatorId.toLongOrNull() ?: return
val postId = item.postId.toLongOrNull() ?: return
startActivity(
Intent(requireContext(), CreatorCommunityAllActivity::class.java).apply {
putExtra(Constants.EXTRA_COMMUNITY_CREATOR_ID, creatorId)
putExtra(Constants.EXTRA_COMMUNITY_POST_ID, postId)
putExtra(Constants.EXTRA_COMMUNITY_EXIST_ORDERED, item.existOrdered)
}
)
ensureMainV2NavigationAllowed {
startActivity(
Intent(requireContext(), CreatorCommunityAllActivity::class.java).apply {
putExtra(Constants.EXTRA_COMMUNITY_CREATOR_ID, creatorId)
putExtra(Constants.EXTRA_COMMUNITY_POST_ID, postId)
putExtra(Constants.EXTRA_COMMUNITY_EXIST_ORDERED, item.existOrdered)
}
)
}
}
private fun showToast(toastMessage: ToastMessage) {