mirror of
https://github.com/mihonapp/mihon.git
synced 2024-11-07 03:07:25 +01:00
Avoid some crashes if router backstack is empty for whatever reason
This commit is contained in:
parent
fad1449de3
commit
c284a23afb
@ -96,7 +96,7 @@ class BrowseController :
|
|||||||
/* It's possible to switch to the Library controller by the time setExtensionUpdateBadge
|
/* It's possible to switch to the Library controller by the time setExtensionUpdateBadge
|
||||||
is called, resulting in a badge being put on the category tabs (if enabled).
|
is called, resulting in a badge being put on the category tabs (if enabled).
|
||||||
This check prevents that from happening */
|
This check prevents that from happening */
|
||||||
if (router.backstack.last().controller !is BrowseController) return
|
if (router.backstack.lastOrNull()?.controller !is BrowseController) return
|
||||||
|
|
||||||
(activity as? MainActivity)?.binding?.tabs?.apply {
|
(activity as? MainActivity)?.binding?.tabs?.apply {
|
||||||
val updates = preferences.extensionUpdatesCount().get()
|
val updates = preferences.extensionUpdatesCount().get()
|
||||||
|
@ -76,7 +76,7 @@ class SearchController(
|
|||||||
router.popController(this)
|
router.popController(this)
|
||||||
if (newManga != null) {
|
if (newManga != null) {
|
||||||
val newMangaController = RouterTransaction.with(MangaController(newManga))
|
val newMangaController = RouterTransaction.with(MangaController(newManga))
|
||||||
if (router.backstack.last().controller is MangaController) {
|
if (router.backstack.lastOrNull()?.controller is MangaController) {
|
||||||
// Replace old MangaController
|
// Replace old MangaController
|
||||||
router.replaceTopController(newMangaController)
|
router.replaceTopController(newMangaController)
|
||||||
} else {
|
} else {
|
||||||
|
@ -409,7 +409,7 @@ class MainActivity : BaseViewBindingActivity<MainActivityBinding>() {
|
|||||||
}
|
}
|
||||||
SHORTCUT_MANGA -> {
|
SHORTCUT_MANGA -> {
|
||||||
val extras = intent.extras ?: return false
|
val extras = intent.extras ?: return false
|
||||||
val fgController = router.backstack.last()?.controller as? MangaController
|
val fgController = router.backstack.lastOrNull()?.controller as? MangaController
|
||||||
if (fgController?.manga?.id != extras.getLong(MangaController.MANGA_EXTRA)) {
|
if (fgController?.manga?.id != extras.getLong(MangaController.MANGA_EXTRA)) {
|
||||||
router.popToRoot()
|
router.popToRoot()
|
||||||
setSelectedNavItem(R.id.nav_library)
|
setSelectedNavItem(R.id.nav_library)
|
||||||
|
Loading…
Reference in New Issue
Block a user