Remove unnecessary method

This commit is contained in:
Kirill Kamakin
2022-11-05 11:08:12 +01:00
parent 7800d7e754
commit 39ce70f964

View File

@@ -79,7 +79,14 @@ class RecipesFragment : Fragment(R.layout.fragment_recipes) {
binding.refresher.isRefreshing = false
}
recipesAdapter.observeLoadStateChanges()
collectWhenViewResumed(recipesAdapter.appendPaginationEnd()) {
logger.v { "onPaginationEnd() called" }
showLongToast(R.string.fragment_recipes_last_page_loaded_toast)
}
collectWhenViewResumed(recipesAdapter.refreshErrors()) {
onLoadFailure(it)
}
collectWhenViewResumed(binding.refresher.refreshRequestFlow(logger)) {
logger.v { "setupRecipeAdapter: received refresh request" }
@@ -96,16 +103,6 @@ class RecipesFragment : Fragment(R.layout.fragment_recipes) {
}
}
private fun <T : Any, VH : RecyclerView.ViewHolder> PagingDataAdapter<T, VH>.observeLoadStateChanges() {
collectWhenViewResumed(appendPaginationEnd()) { onPaginationEnd() }
collectWhenViewResumed(refreshErrors()) { onLoadFailure(it) }
}
private fun onPaginationEnd() {
logger.v { "onPaginationEnd() called" }
showLongToast(R.string.fragment_recipes_last_page_loaded_toast)
}
private fun onLoadFailure(error: Throwable) {
logger.w(error) { "onLoadFailure() called" }
val reason = error.toLoadErrorReasonText()?.let { getString(it) }