From 212f32b52d44ee3489638742b057df346588a10c Mon Sep 17 00:00:00 2001 From: Nick Bradbury Date: Thu, 21 Nov 2024 11:43:54 -0500 Subject: [PATCH] Reverted changes to CampaignListingFragment --- .../CampaignListingFragment.kt | 25 ++++++------------- 1 file changed, 7 insertions(+), 18 deletions(-) diff --git a/WordPress/src/main/java/org/wordpress/android/ui/blaze/blazecampaigns/campaignlisting/CampaignListingFragment.kt b/WordPress/src/main/java/org/wordpress/android/ui/blaze/blazecampaigns/campaignlisting/CampaignListingFragment.kt index 78ad17f09e0e..11ed791a8e26 100644 --- a/WordPress/src/main/java/org/wordpress/android/ui/blaze/blazecampaigns/campaignlisting/CampaignListingFragment.kt +++ b/WordPress/src/main/java/org/wordpress/android/ui/blaze/blazecampaigns/campaignlisting/CampaignListingFragment.kt @@ -80,23 +80,8 @@ class CampaignListingFragment : Fragment() { } private val viewModel: CampaignListingViewModel by viewModels() - private val campaignViewModel: CampaignViewModel by activityViewModels() - - private var pageSource: CampaignListingPageSource? = null - - override fun onCreate(savedInstanceState: Bundle?) { - super.onCreate(savedInstanceState) - pageSource = savedInstanceState?.getSerializableCompat(CAMPAIGN_LISTING_PAGE_SOURCE) - ?: arguments?.getSerializableCompat(CAMPAIGN_LISTING_PAGE_SOURCE) - if (pageSource == null) { - pageSource = CampaignListingPageSource.UNKNOWN - } - } - override fun onSaveInstanceState(outState: Bundle) { - super.onSaveInstanceState(outState) - outState.putSerializable(CAMPAIGN_LISTING_PAGE_SOURCE, pageSource) - } + private val campaignViewModel: CampaignViewModel by activityViewModels() override fun onCreateView( inflater: LayoutInflater, container: ViewGroup?, @@ -112,7 +97,7 @@ class CampaignListingFragment : Fragment() { override fun onViewCreated(view: View, savedInstanceState: Bundle?) { super.onViewCreated(view, savedInstanceState) - viewModel.start(pageSource!!) + viewModel.start(getPageSource()) initObservers() } @@ -140,6 +125,11 @@ class CampaignListingFragment : Fragment() { } } + private fun getPageSource(): CampaignListingPageSource { + return arguments?.getSerializableCompat(CAMPAIGN_LISTING_PAGE_SOURCE) + ?: CampaignListingPageSource.UNKNOWN + } + @OptIn(ExperimentalMaterial3Api::class) @Composable fun CampaignListingPage(uiState: CampaignListingUiState) { @@ -317,4 +307,3 @@ fun CampaignListingErrorPreview() { )) } } -