Skip to content

Commit

Permalink
[AN/USER] fix: 사용자 불편사항 및 오동작 해결(#980 #983 #984) (#981)
Browse files Browse the repository at this point in the history
* feat: 바텀 네비게이션 클릭 시 쌓였던 BackStack 이 초기화된다.

* feat(FestivalList): 다른 화면에서 돌아왔을 때 재요청이 일어나지 않는다

* feat: 첫번째 요청 결과 last 인데 현재 진행, 예정만 있다면 과거 요청을 한번 더 보낸다

* style: ktlint check

* chore: update to 2.1.0
  • Loading branch information
SeongHoonC authored May 19, 2024
1 parent e0677a4 commit efc9ebc
Show file tree
Hide file tree
Showing 6 changed files with 32 additions and 5 deletions.
2 changes: 1 addition & 1 deletion android/festago/app/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ android {
minSdk = 28
targetSdk = 34
versionCode = 13
versionName = "2.0.4"
versionName = "2.1.0"

testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,8 +70,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)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -60,9 +61,23 @@ class HomeActivity : AppCompatActivity() {
(supportFragmentManager.findFragmentById(R.id.fcvHomeContainer) as NavHostFragment).navController
val bottomNavigationView = findViewById<BottomNavigationView>(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)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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() }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,8 +68,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)
Expand Down

0 comments on commit efc9ebc

Please sign in to comment.