Hide Start/Resume FAB unless there are unread chapters and during loading (#5458)

* Hide Start/Resume FAB unless there are unread chapters

* Remove dead code, rewrite logic for hiding FAB
This commit is contained in:
Hunter Nickel 2021-07-12 09:48:48 -06:00 committed by GitHub
parent 2e487f8a3f
commit a6d4a3b785
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -270,6 +270,8 @@ class MangaController :
chaptersAdapter?.fastScroller = binding.fastScroller chaptersAdapter?.fastScroller = binding.fastScroller
actionFabScrollListener = actionFab?.shrinkOnScroll(chapterRecycler) actionFabScrollListener = actionFab?.shrinkOnScroll(chapterRecycler)
// Initially set FAB invisible; will become visible if unread chapters are present
actionFab?.isVisible = false
binding.swipeRefresh.refreshes() binding.swipeRefresh.refreshes()
.onEach { .onEach {
@ -333,8 +335,6 @@ class MangaController :
} }
) )
} }
} else {
view?.context?.toast(R.string.no_next_chapter)
} }
} }
} }
@ -775,10 +775,13 @@ class MangaController :
} }
val context = view?.context val context = view?.context
if (context != null && chapters.any { it.read }) { if (context != null) {
actionFab?.isVisible = chapters.any { !it.read }
if (chapters.any { it.read }) {
actionFab?.text = context.getString(R.string.action_resume) actionFab?.text = context.getString(R.string.action_resume)
} }
} }
}
private fun fetchChaptersFromSource(manualFetch: Boolean = false) { private fun fetchChaptersFromSource(manualFetch: Boolean = false) {
isRefreshingChapters = true isRefreshingChapters = true