diff --git a/android/festago/app/build.gradle.kts b/android/festago/app/build.gradle.kts index b2d2820e7..9745bdb39 100644 --- a/android/festago/app/build.gradle.kts +++ b/android/festago/app/build.gradle.kts @@ -17,7 +17,7 @@ android { minSdk = 28 targetSdk = 34 versionCode = 13 - versionName = "2.0.4" + versionName = "2.1.0" testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner" } diff --git a/android/festago/presentation/src/main/java/com/festago/festago/presentation/ui/artistdetail/ArtistDetailViewModel.kt b/android/festago/presentation/src/main/java/com/festago/festago/presentation/ui/artistdetail/ArtistDetailViewModel.kt index 091935f53..5d0e40078 100644 --- a/android/festago/presentation/src/main/java/com/festago/festago/presentation/ui/artistdetail/ArtistDetailViewModel.kt +++ b/android/festago/presentation/src/main/java/com/festago/festago/presentation/ui/artistdetail/ArtistDetailViewModel.kt @@ -67,8 +67,13 @@ class ArtistDetailViewModel @Inject constructor( onBookmarkClick = ::toggleArtistBookmark, ) - if (festivalPage.festivals.isEmpty()) { + if (!festivalPage.isLastPage) { + return@launch + } + val lastFestival = festivalPage.festivals.lastOrNull() + if (lastFestival == null || lastFestival.endDate >= LocalDate.now()) { loadMoreArtistFestivals(id) + return@launch } }.onFailure { handleFailure(key = KEY_LOAD_ARTIST_DETAIL, throwable = it) diff --git a/android/festago/presentation/src/main/java/com/festago/festago/presentation/ui/home/HomeActivity.kt b/android/festago/presentation/src/main/java/com/festago/festago/presentation/ui/home/HomeActivity.kt index 40a18ec52..3992245cf 100644 --- a/android/festago/presentation/src/main/java/com/festago/festago/presentation/ui/home/HomeActivity.kt +++ b/android/festago/presentation/src/main/java/com/festago/festago/presentation/ui/home/HomeActivity.kt @@ -14,6 +14,7 @@ import androidx.core.view.WindowCompat import androidx.core.view.WindowInsetsCompat import androidx.core.view.WindowInsetsControllerCompat import androidx.navigation.NavController +import androidx.navigation.NavOptions import androidx.navigation.fragment.NavHostFragment import androidx.navigation.ui.setupWithNavController import com.festago.festago.presentation.R @@ -60,9 +61,23 @@ class HomeActivity : AppCompatActivity() { (supportFragmentManager.findFragmentById(R.id.fcvHomeContainer) as NavHostFragment).navController val bottomNavigationView = findViewById(R.id.nvHome) bottomNavigationView.setupWithNavController(navController) + + setBottomNavPopUpBackstack(bottomNavigationView) setNavColor() } + private fun setBottomNavPopUpBackstack(bottomNavigationView: BottomNavigationView) { + bottomNavigationView.setOnItemSelectedListener { + val options = NavOptions.Builder() + .setPopUpTo(R.id.main_graph_xml, false) + .setLaunchSingleTop(true) + .build() + + navController.navigate(it.itemId, null, options) + true + } + } + private fun setNavColor() { window.addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS) window.navigationBarColor = ContextCompat.getColor(this, android.R.color.white) diff --git a/android/festago/presentation/src/main/java/com/festago/festago/presentation/ui/home/festivallist/FestivalListFragment.kt b/android/festago/presentation/src/main/java/com/festago/festago/presentation/ui/home/festivallist/FestivalListFragment.kt index 0cda1e379..4697420bb 100644 --- a/android/festago/presentation/src/main/java/com/festago/festago/presentation/ui/home/festivallist/FestivalListFragment.kt +++ b/android/festago/presentation/src/main/java/com/festago/festago/presentation/ui/home/festivallist/FestivalListFragment.kt @@ -82,7 +82,7 @@ class FestivalListFragment : Fragment() { private fun initRefresh() { binding.srlFestivalList.setOnRefreshListener { - vm.initFestivalList() + vm.initFestivalList(true) binding.srlFestivalList.isRefreshing = false } binding.srlFestivalList.setDistanceToTriggerSync(400) diff --git a/android/festago/presentation/src/main/java/com/festago/festago/presentation/ui/home/festivallist/FestivalListViewModel.kt b/android/festago/presentation/src/main/java/com/festago/festago/presentation/ui/home/festivallist/FestivalListViewModel.kt index 575a03315..64d6a7542 100644 --- a/android/festago/presentation/src/main/java/com/festago/festago/presentation/ui/home/festivallist/FestivalListViewModel.kt +++ b/android/festago/presentation/src/main/java/com/festago/festago/presentation/ui/home/festivallist/FestivalListViewModel.kt @@ -38,7 +38,9 @@ class FestivalListViewModel @Inject constructor( private var festivalFilter: FestivalFilter = FestivalFilter.PROGRESS - fun initFestivalList() { + fun initFestivalList(refresh: Boolean = false) { + if (!refresh && uiState.value is FestivalListUiState.Success) return + viewModelScope.launch { val schoolRegion = (uiState.value as? FestivalListUiState.Success)?.schoolRegion val deferredPopularFestivals = async { festivalRepository.loadPopularFestivals() } diff --git a/android/festago/presentation/src/main/java/com/festago/festago/presentation/ui/schooldetail/SchoolDetailViewModel.kt b/android/festago/presentation/src/main/java/com/festago/festago/presentation/ui/schooldetail/SchoolDetailViewModel.kt index 379a3edd2..1afbe15ba 100644 --- a/android/festago/presentation/src/main/java/com/festago/festago/presentation/ui/schooldetail/SchoolDetailViewModel.kt +++ b/android/festago/presentation/src/main/java/com/festago/festago/presentation/ui/schooldetail/SchoolDetailViewModel.kt @@ -65,8 +65,13 @@ class SchoolDetailViewModel @Inject constructor( isLast = festivalPage.isLastPage, onBookmarkClick = { schoolId -> toggleSchoolBookmark(schoolId) }, ) - if (festivalPage.festivals.isEmpty()) { + if (!festivalPage.isLastPage) { + return@launch + } + val lastFestival = festivalPage.festivals.lastOrNull() + if (lastFestival == null || lastFestival.endDate >= LocalDate.now()) { loadMoreSchoolFestivals(schoolId) + return@launch } }.onFailure { handleFailure(key = KEY_LOAD_SCHOOL_DETAIL, throwable = it)