Skip to content

Commit

Permalink
[#3948] Replace restartApp logic with recreate() (#3949)
Browse files Browse the repository at this point in the history
  • Loading branch information
mustafaozhan authored Sep 16, 2024
1 parent 425b465 commit 2f4b3eb
Showing 1 changed file with 3 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ import com.oztechan.ccc.android.core.billing.BillingManager
import com.oztechan.ccc.android.ui.mobile.BuildConfig
import com.oztechan.ccc.android.ui.mobile.R
import com.oztechan.ccc.android.ui.mobile.databinding.BottomSheetPremiumBinding
import com.oztechan.ccc.android.ui.mobile.util.resolveAndStartIntent
import com.oztechan.ccc.android.ui.mobile.util.showDialog
import com.oztechan.ccc.android.ui.mobile.util.showSnack
import com.oztechan.ccc.android.ui.mobile.util.toOldPurchaseList
Expand Down Expand Up @@ -108,10 +107,11 @@ class PremiumBottomSheet : BaseVBBottomSheetDialogFragment<BottomSheetPremiumBin
viewEffect.premiumType == PremiumType.VIDEO ||
viewEffect.isRestorePurchase
) {
restartActivity()
requireActivity().recreate()
} else {
billingManager.acknowledgePurchase()
}

is PremiumEffect.ConsumePurchase -> billingManager.consumePurchase(viewEffect.token)
}
}.launchIn(viewLifecycleOwner.lifecycleScope)
Expand All @@ -121,7 +121,7 @@ class PremiumBottomSheet : BaseVBBottomSheetDialogFragment<BottomSheetPremiumBin
.onEach { viewEffect ->
Logger.i { "PremiumBottomSheet observeBillingEffects ${viewEffect::class.simpleName}" }
when (viewEffect) {
BillingEffect.SuccessfulPurchase -> restartActivity()
BillingEffect.SuccessfulPurchase -> requireActivity().recreate()
is BillingEffect.RestoreOrConsumePurchase -> viewModel.event.onRestoreOrConsumePurchase(
viewEffect.purchaseList.toOldPurchaseList()
)
Expand Down Expand Up @@ -155,9 +155,4 @@ class PremiumBottomSheet : BaseVBBottomSheetDialogFragment<BottomSheetPremiumBin
}
)
}

private fun restartActivity() = activity?.run {
finish()
resolveAndStartIntent(intent)
}
}

0 comments on commit 2f4b3eb

Please sign in to comment.