From ae88252cb189283a87c3294c0b6c4bb28064b0f6 Mon Sep 17 00:00:00 2001 From: Ivan Iskandar <12537387+ivaniskandar@users.noreply.github.com> Date: Sat, 18 Jun 2022 04:28:50 +0700 Subject: [PATCH] MangaController: Change the workaround for title alpha (#7277) Now checks for the backstack for any dialog controller when a push exit occurs before restoring the title alpha. --- .../tachiyomi/ui/manga/MangaController.kt | 37 +++++-------------- 1 file changed, 9 insertions(+), 28 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 74ee7a171..a7813a5c4 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 @@ -26,7 +26,6 @@ import androidx.recyclerview.widget.RecyclerView import androidx.swiperefreshlayout.widget.SwipeRefreshLayout import coil.imageLoader import coil.request.ImageRequest -import com.bluelinelabs.conductor.Controller import com.bluelinelabs.conductor.ControllerChangeHandler import com.bluelinelabs.conductor.ControllerChangeType import com.google.android.material.floatingactionbutton.ExtendedFloatingActionButton @@ -182,8 +181,6 @@ class MangaController : private var trackSheet: TrackSheet? = null - private var dialog: DialogController? = null - /** * For [recyclerViewUpdatesToolbarTitleAlpha] */ @@ -206,8 +203,10 @@ class MangaController : super.onChangeStarted(handler, type) // Hide toolbar title on enter // No need to update alpha for cover dialog - if (dialog == null) { - updateToolbarTitleAlpha(if (type.isEnter) 0F else 1F) + if (!type.isEnter) { + if (!type.isPush || router.backstack.lastOrNull()?.controller !is DialogController) { + updateToolbarTitleAlpha(1f) + } } recyclerViewUpdatesToolbarTitleAlpha(type.isEnter) } @@ -623,17 +622,8 @@ class MangaController : } 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) + ChangeMangaCategoriesDialog(this, listOf(manga), categories, preselected) + .showDialog(router) } override fun updateCategoriesForMangas(mangas: List, addCategories: List, removeCategories: List) { @@ -731,18 +721,9 @@ class MangaController : } fun showFullCoverDialog() { - if (dialog != null) return val manga = manga ?: return - dialog = MangaFullCoverDialog(this, manga) - dialog?.addLifecycleListener( - object : LifecycleListener() { - override fun postDestroy(controller: Controller) { - super.postDestroy(controller) - dialog = null - } - }, - ) - dialog?.showDialog(router) + MangaFullCoverDialog(this, manga) + .showDialog(router) } fun shareCover() { @@ -838,7 +819,7 @@ class MangaController : fun onSetCoverSuccess() { mangaInfoAdapter?.notifyItemChanged(0, this) - (dialog as? MangaFullCoverDialog)?.setImage(manga) + (router.backstack.lastOrNull()?.controller as? MangaFullCoverDialog)?.setImage(manga) activity?.toast(R.string.cover_updated) }