Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[AN/USER] fix: 사용자 불편사항 및 오동작 해결(#980 #983 #984) #981

Merged
merged 5 commits into from
May 19, 2024
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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)
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 @@ -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)
Expand Down
Loading