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.
This commit is contained in:
parent
3c3d787a2b
commit
ae88252cb1
1 changed files with 9 additions and 28 deletions
|
@ -26,7 +26,6 @@ import androidx.recyclerview.widget.RecyclerView
|
||||||
import androidx.swiperefreshlayout.widget.SwipeRefreshLayout
|
import androidx.swiperefreshlayout.widget.SwipeRefreshLayout
|
||||||
import coil.imageLoader
|
import coil.imageLoader
|
||||||
import coil.request.ImageRequest
|
import coil.request.ImageRequest
|
||||||
import com.bluelinelabs.conductor.Controller
|
|
||||||
import com.bluelinelabs.conductor.ControllerChangeHandler
|
import com.bluelinelabs.conductor.ControllerChangeHandler
|
||||||
import com.bluelinelabs.conductor.ControllerChangeType
|
import com.bluelinelabs.conductor.ControllerChangeType
|
||||||
import com.google.android.material.floatingactionbutton.ExtendedFloatingActionButton
|
import com.google.android.material.floatingactionbutton.ExtendedFloatingActionButton
|
||||||
|
@ -182,8 +181,6 @@ class MangaController :
|
||||||
|
|
||||||
private var trackSheet: TrackSheet? = null
|
private var trackSheet: TrackSheet? = null
|
||||||
|
|
||||||
private var dialog: DialogController? = null
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* For [recyclerViewUpdatesToolbarTitleAlpha]
|
* For [recyclerViewUpdatesToolbarTitleAlpha]
|
||||||
*/
|
*/
|
||||||
|
@ -206,8 +203,10 @@ class MangaController :
|
||||||
super.onChangeStarted(handler, type)
|
super.onChangeStarted(handler, type)
|
||||||
// Hide toolbar title on enter
|
// Hide toolbar title on enter
|
||||||
// No need to update alpha for cover dialog
|
// No need to update alpha for cover dialog
|
||||||
if (dialog == null) {
|
if (!type.isEnter) {
|
||||||
updateToolbarTitleAlpha(if (type.isEnter) 0F else 1F)
|
if (!type.isPush || router.backstack.lastOrNull()?.controller !is DialogController) {
|
||||||
|
updateToolbarTitleAlpha(1f)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
recyclerViewUpdatesToolbarTitleAlpha(type.isEnter)
|
recyclerViewUpdatesToolbarTitleAlpha(type.isEnter)
|
||||||
}
|
}
|
||||||
|
@ -623,17 +622,8 @@ class MangaController :
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun showChangeCategoryDialog(manga: Manga, categories: List<Category>, preselected: Array<Int>) {
|
private fun showChangeCategoryDialog(manga: Manga, categories: List<Category>, preselected: Array<Int>) {
|
||||||
if (dialog != null) return
|
ChangeMangaCategoriesDialog(this, listOf(manga), categories, preselected)
|
||||||
dialog = ChangeMangaCategoriesDialog(this, listOf(manga), categories, preselected)
|
.showDialog(router)
|
||||||
dialog?.addLifecycleListener(
|
|
||||||
object : LifecycleListener() {
|
|
||||||
override fun postDestroy(controller: Controller) {
|
|
||||||
super.postDestroy(controller)
|
|
||||||
dialog = null
|
|
||||||
}
|
|
||||||
},
|
|
||||||
)
|
|
||||||
dialog?.showDialog(router)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun updateCategoriesForMangas(mangas: List<Manga>, addCategories: List<Category>, removeCategories: List<Category>) {
|
override fun updateCategoriesForMangas(mangas: List<Manga>, addCategories: List<Category>, removeCategories: List<Category>) {
|
||||||
|
@ -731,18 +721,9 @@ class MangaController :
|
||||||
}
|
}
|
||||||
|
|
||||||
fun showFullCoverDialog() {
|
fun showFullCoverDialog() {
|
||||||
if (dialog != null) return
|
|
||||||
val manga = manga ?: return
|
val manga = manga ?: return
|
||||||
dialog = MangaFullCoverDialog(this, manga)
|
MangaFullCoverDialog(this, manga)
|
||||||
dialog?.addLifecycleListener(
|
.showDialog(router)
|
||||||
object : LifecycleListener() {
|
|
||||||
override fun postDestroy(controller: Controller) {
|
|
||||||
super.postDestroy(controller)
|
|
||||||
dialog = null
|
|
||||||
}
|
|
||||||
},
|
|
||||||
)
|
|
||||||
dialog?.showDialog(router)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fun shareCover() {
|
fun shareCover() {
|
||||||
|
@ -838,7 +819,7 @@ class MangaController :
|
||||||
|
|
||||||
fun onSetCoverSuccess() {
|
fun onSetCoverSuccess() {
|
||||||
mangaInfoAdapter?.notifyItemChanged(0, this)
|
mangaInfoAdapter?.notifyItemChanged(0, this)
|
||||||
(dialog as? MangaFullCoverDialog)?.setImage(manga)
|
(router.backstack.lastOrNull()?.controller as? MangaFullCoverDialog)?.setImage(manga)
|
||||||
activity?.toast(R.string.cover_updated)
|
activity?.toast(R.string.cover_updated)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Reference in a new issue