From 2e2663bad9a627c1eb3093cb0f1f1e9fdf31cf3f Mon Sep 17 00:00:00 2001 From: arkon Date: Fri, 12 Feb 2021 16:55:14 -0500 Subject: [PATCH] Avoid crash if activity is already dead --- .../java/eu/kanade/tachiyomi/ui/library/LibraryController.kt | 4 ++-- .../main/java/eu/kanade/tachiyomi/ui/manga/MangaController.kt | 4 ++-- .../kanade/tachiyomi/ui/recent/updates/UpdatesController.kt | 4 ++-- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/library/LibraryController.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/library/LibraryController.kt index c976c76bc..e58827f1d 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/library/LibraryController.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/library/LibraryController.kt @@ -217,7 +217,7 @@ class LibraryController( } .launchIn(viewScope) - (activity!! as MainActivity).fixViewToBottom(binding.actionToolbar) + (activity as? MainActivity)?.fixViewToBottom(binding.actionToolbar) } override fun onChangeStarted(handler: ControllerChangeHandler, type: ControllerChangeType) { @@ -230,7 +230,7 @@ class LibraryController( override fun onDestroyView(view: View) { destroyActionModeIfNeeded() - (activity!! as MainActivity).clearFixViewToBottom(binding.actionToolbar) + (activity as? MainActivity)?.clearFixViewToBottom(binding.actionToolbar) binding.actionToolbar.destroy() adapter?.onDestroy() adapter = null 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 1c43079ee..028e83b82 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 @@ -242,7 +242,7 @@ class MangaController : } .launchIn(viewScope) - (activity!! as MainActivity).fixViewToBottom(binding.actionToolbar) + (activity as? MainActivity)?.fixViewToBottom(binding.actionToolbar) settingsSheet = ChaptersSettingsSheet(router, presenter) { group -> if (group is ChaptersSettingsSheet.Filter.FilterGroup) { @@ -321,7 +321,7 @@ class MangaController : override fun onDestroyView(view: View) { destroyActionModeIfNeeded() - (activity!! as MainActivity).clearFixViewToBottom(binding.actionToolbar) + (activity as? MainActivity)?.clearFixViewToBottom(binding.actionToolbar) binding.actionToolbar.destroy() mangaInfoAdapter = null chaptersHeaderAdapter = null diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/recent/updates/UpdatesController.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/recent/updates/UpdatesController.kt index 73960a235..16c51c6a4 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/recent/updates/UpdatesController.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/recent/updates/UpdatesController.kt @@ -109,12 +109,12 @@ class UpdatesController : } .launchIn(viewScope) - (activity!! as MainActivity).fixViewToBottom(binding.actionToolbar) + (activity as? MainActivity)?.fixViewToBottom(binding.actionToolbar) } override fun onDestroyView(view: View) { destroyActionModeIfNeeded() - (activity!! as MainActivity).clearFixViewToBottom(binding.actionToolbar) + (activity as? MainActivity)?.clearFixViewToBottom(binding.actionToolbar) binding.actionToolbar.destroy() adapter = null super.onDestroyView(view)