From 1f93f82752a6dd24e73fe91b5a3079d466c766e3 Mon Sep 17 00:00:00 2001 From: Jays2Kings Date: Sun, 11 Apr 2021 16:31:17 -0400 Subject: [PATCH] More crash fixes --- .../eu/kanade/tachiyomi/ui/base/activity/BaseActivity.kt | 1 + .../tachiyomi/ui/base/controller/BaseController.kt | 1 + .../eu/kanade/tachiyomi/ui/library/LibraryController.kt | 2 +- .../java/eu/kanade/tachiyomi/ui/main/MainActivity.kt | 1 + .../eu/kanade/tachiyomi/ui/recents/RecentsController.kt | 9 ++++----- .../eu/kanade/tachiyomi/ui/source/BrowseController.kt | 1 + 6 files changed, 9 insertions(+), 6 deletions(-) diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/base/activity/BaseActivity.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/base/activity/BaseActivity.kt index 138d0c8467..5ba5c19200 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/base/activity/BaseActivity.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/base/activity/BaseActivity.kt @@ -15,6 +15,7 @@ abstract class BaseActivity : AppCompatActivity() { val preferences: PreferencesHelper by injectLazy() lateinit var binding: VB + val isBindingInitialized get() = this::binding.isInitialized init { @Suppress("LeakingThis") diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/base/controller/BaseController.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/base/controller/BaseController.kt index b28fdc11a9..c38933f17a 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/base/controller/BaseController.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/base/controller/BaseController.kt @@ -18,6 +18,7 @@ abstract class BaseController(bundle: Bundle? = null) : lateinit var binding: VB + val isBindingInitialized get() = this::binding.isInitialized init { addLifecycleListener( object : LifecycleListener() { 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 91d7262d6c..3a38417e8a 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 @@ -805,7 +805,7 @@ class LibraryController( override fun onActivityResumed(activity: Activity) { super.onActivityResumed(activity) - if (view == null) return + if (!isBindingInitialized) return updateFilterSheetY() if (observeLater && ::presenter.isInitialized) { presenter.getLibrary() diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/main/MainActivity.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/main/MainActivity.kt index 824b282c30..a4ac7feeeb 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/main/MainActivity.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/main/MainActivity.kt @@ -395,6 +395,7 @@ open class MainActivity : BaseActivity(), DownloadServiceLi if (router.backstackSize == 1 && this !is SearchActivity && downloadManager.hasQueue() && !preferences.shownDownloadQueueTutorial().get() ) { + if (!isBindingInitialized) return val recentsItem = binding.bottomNav.getItemView(R.id.nav_recents) ?: return preferences.shownDownloadQueueTutorial().set(true) TapTargetView.showFor( diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/recents/RecentsController.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/recents/RecentsController.kt index 087721b7a4..8f111f607e 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/recents/RecentsController.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/recents/RecentsController.kt @@ -344,11 +344,10 @@ class RecentsController(bundle: Bundle? = null) : override fun onActivityResumed(activity: Activity) { super.onActivityResumed(activity) - if (view != null) { - refresh() - setBottomPadding() - binding.downloadBottomSheet.dlBottomSheet.update() - } + if (!isBindingInitialized) return + refresh() + setBottomPadding() + binding.downloadBottomSheet.dlBottomSheet.update() } override fun onDestroy() { diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/source/BrowseController.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/source/BrowseController.kt index 1212897b5d..78d3a6acab 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/source/BrowseController.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/source/BrowseController.kt @@ -375,6 +375,7 @@ class BrowseController : override fun onActivityResumed(activity: Activity) { super.onActivityResumed(activity) + if (!isBindingInitialized) return binding.bottomSheet.root.presenter.refreshExtensions() binding.bottomSheet.root.presenter.refreshMigrations() setBottomPadding()