From 141f222d3d022e5a59ee754c88963ccb5553edc6 Mon Sep 17 00:00:00 2001 From: Pantelis Stampoulis Date: Wed, 17 Apr 2024 17:48:38 +0300 Subject: [PATCH] Fixes: NullPointerException in SiteCreationActivity --- .../ui/sitecreation/SiteCreationActivity.kt | 17 +++++------------ 1 file changed, 5 insertions(+), 12 deletions(-) diff --git a/WordPress/src/main/java/org/wordpress/android/ui/sitecreation/SiteCreationActivity.kt b/WordPress/src/main/java/org/wordpress/android/ui/sitecreation/SiteCreationActivity.kt index 15597d2747cd..38ebaa1b95c2 100644 --- a/WordPress/src/main/java/org/wordpress/android/ui/sitecreation/SiteCreationActivity.kt +++ b/WordPress/src/main/java/org/wordpress/android/ui/sitecreation/SiteCreationActivity.kt @@ -118,7 +118,7 @@ class SiteCreationActivity : LocaleAwareActivity(), mainViewModel.preloadThumbnails(this) observeVMState() - observeOverlayEvents(savedInstanceState) + observeOverlayEvents() } override fun onSaveInstanceState(outState: Bundle) { @@ -169,20 +169,13 @@ class SiteCreationActivity : LocaleAwareActivity(), previewViewModel.onOkButtonClicked.observe(this, mainViewModel::onWizardFinished) } - private fun observeOverlayEvents(savedInstanceState: Bundle?) { + private fun observeOverlayEvents() { if(BuildConfig.IS_JETPACK_APP) return - val fragment = if (savedInstanceState == null) { - JetpackFeatureFullScreenOverlayFragment - .newInstance( - isSiteCreationOverlay = true, - siteCreationSource = getSiteCreationSource() - ) - }else { - supportFragmentManager.findFragmentByTag(JetpackFeatureFullScreenOverlayFragment.TAG) - as JetpackFeatureFullScreenOverlayFragment - } + val fragment = supportFragmentManager.findFragmentByTag(JetpackFeatureFullScreenOverlayFragment.TAG) + as? JetpackFeatureFullScreenOverlayFragment ?: JetpackFeatureFullScreenOverlayFragment + .newInstance(isSiteCreationOverlay = true, siteCreationSource = getSiteCreationSource()) jetpackFullScreenViewModel.action.observe(this) { action -> if (mainViewModel.siteCreationDisabled) finish()