From 6e99caf458b465d85f7269ca0d78b5c179d51511 Mon Sep 17 00:00:00 2001 From: Jay Date: Wed, 29 Apr 2020 14:07:18 -0400 Subject: [PATCH] Fixed crash when pressing up arrow in search activity --- .../eu/kanade/tachiyomi/ui/manga/MangaDetailsController.kt | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/manga/MangaDetailsController.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/manga/MangaDetailsController.kt index d909f2fc20..3cd09b4997 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/manga/MangaDetailsController.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/manga/MangaDetailsController.kt @@ -542,9 +542,10 @@ class MangaDetailsController : BaseController, val colorSecondary = activity?.getResourceColor( R.attr.colorSecondary ) ?: Color.BLACK - if (router.backstack.last().controller() !is MangaDetailsController) { - (activity as MainActivity).appbar.setBackgroundColor(colorSecondary) - (activity as MainActivity).toolbar.setBackgroundColor(colorSecondary) + if (router.backstackSize > 0 && + router.backstack.last().controller() !is MangaDetailsController) { + (activity as? MainActivity)?.appbar?.setBackgroundColor(colorSecondary) + (activity as? MainActivity)?.toolbar?.setBackgroundColor(colorSecondary) activity?.window?.statusBarColor = activity?.getResourceColor( android.R.attr.statusBarColor