Skip to content

Commit

Permalink
Reverted changes to CampaignListingFragment
Browse files Browse the repository at this point in the history
  • Loading branch information
nbradbury committed Nov 21, 2024
1 parent 4f5cf90 commit 212f32b
Showing 1 changed file with 7 additions and 18 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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?,
Expand All @@ -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()
}

Expand Down Expand Up @@ -140,6 +125,11 @@ class CampaignListingFragment : Fragment() {
}
}

private fun getPageSource(): CampaignListingPageSource {
return arguments?.getSerializableCompat<CampaignListingPageSource>(CAMPAIGN_LISTING_PAGE_SOURCE)
?: CampaignListingPageSource.UNKNOWN
}

@OptIn(ExperimentalMaterial3Api::class)
@Composable
fun CampaignListingPage(uiState: CampaignListingUiState) {
Expand Down Expand Up @@ -317,4 +307,3 @@ fun CampaignListingErrorPreview() {
))
}
}

0 comments on commit 212f32b

Please sign in to comment.