From 24b967ad5c06cb663f19e98a31b59ed8ec4a4b1f Mon Sep 17 00:00:00 2001 From: Hunter Nickel Date: Tue, 17 Aug 2021 20:44:35 -0600 Subject: [PATCH] Fix start/resume fab showing up when entering and then exiting action mode (#5735) --- .../tachiyomi/ui/manga/MangaController.kt | 20 +++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/manga/MangaController.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/manga/MangaController.kt index 721ae1d331..9970ed5f98 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/manga/MangaController.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/manga/MangaController.kt @@ -350,6 +350,16 @@ class MangaController : actionFab = null } + private fun updateFabVisibility() { + val context = view?.context ?: return + val adapter = chaptersAdapter ?: return + val fab = actionFab ?: return + fab.isVisible = adapter.items.any { !it.read } + if (adapter.items.any { it.read }) { + fab.text = context.getString(R.string.action_resume) + } + } + override fun onDestroyView(view: View) { destroyActionModeIfNeeded() (activity as? MainActivity)?.clearFixViewToBottom(binding.actionToolbar) @@ -800,13 +810,7 @@ class MangaController : actionMode?.invalidate() } - val context = view?.context - if (context != null) { - actionFab?.isVisible = chapters.any { !it.read } - if (chapters.any { it.read }) { - actionFab?.text = context.getString(R.string.action_resume) - } - } + updateFabVisibility() } private fun fetchChaptersFromSource(manualFetch: Boolean = false) { @@ -988,7 +992,7 @@ class MangaController : chaptersAdapter?.clearSelection() selectedChapters.clear() actionMode = null - actionFab?.isVisible = true + updateFabVisibility() } override fun onDetach(view: View) {