From ef993515c6b6169febf2a55df44fb9ca1b0b0a71 Mon Sep 17 00:00:00 2001 From: Ivan Iskandar <12537387+ivaniskandar@users.noreply.github.com> Date: Sat, 2 Oct 2021 04:52:06 +0700 Subject: [PATCH] Fix MangaController toolbar title showing when editing category (#6005) --- .../tachiyomi/ui/manga/MangaController.kt | 25 ++++++++++++++----- 1 file changed, 19 insertions(+), 6 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 56fe664bbe..2804a6aacf 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 @@ -53,6 +53,7 @@ import eu.kanade.tachiyomi.source.LocalSource import eu.kanade.tachiyomi.source.Source import eu.kanade.tachiyomi.source.SourceManager import eu.kanade.tachiyomi.source.online.HttpSource +import eu.kanade.tachiyomi.ui.base.controller.DialogController import eu.kanade.tachiyomi.ui.base.controller.FabController import eu.kanade.tachiyomi.ui.base.controller.NucleusController import eu.kanade.tachiyomi.ui.base.controller.getMainAppBarHeight @@ -177,7 +178,7 @@ class MangaController : private var trackSheet: TrackSheet? = null - private var dialog: MangaFullCoverDialog? = null + private var dialog: DialogController? = null /** * For [recyclerViewUpdatesToolbarTitleAlpha] @@ -583,8 +584,7 @@ class MangaController : } }.toTypedArray() - ChangeMangaCategoriesDialog(this, listOf(manga), categories, preselected) - .showDialog(router) + showChangeCategoryDialog(manga, categories, preselected) } } @@ -637,8 +637,21 @@ class MangaController : QuadStateTextView.State.UNCHECKED.ordinal } }.toTypedArray() - ChangeMangaCategoriesDialog(this, listOf(manga), categories, preselected) - .showDialog(router) + showChangeCategoryDialog(manga, categories, preselected) + } + + private fun showChangeCategoryDialog(manga: Manga, categories: List, preselected: Array) { + if (dialog != null) return + dialog = ChangeMangaCategoriesDialog(this, listOf(manga), categories, preselected) + dialog?.addLifecycleListener( + object : LifecycleListener() { + override fun postDestroy(controller: Controller) { + super.postDestroy(controller) + dialog = null + } + } + ) + dialog?.showDialog(router) } override fun updateCategoriesForMangas(mangas: List, addCategories: List, removeCategories: List) { @@ -822,7 +835,7 @@ class MangaController : fun onSetCoverSuccess() { mangaInfoAdapter?.notifyDataSetChanged() - dialog?.setImage(manga) + (dialog as? MangaFullCoverDialog)?.setImage(manga) activity?.toast(R.string.cover_updated) }