mirror of
https://github.com/sudoxnym/habitica-android.git
synced 2026-07-08 21:37:53 +00:00
queryPurchasesAsync run onResume instead of init block
This commit is contained in:
parent
441dfa5498
commit
f9fa49cf84
4 changed files with 18 additions and 8 deletions
|
|
@ -103,14 +103,7 @@ open class PurchaseHandler(
|
|||
override fun onBillingSetupFinished(billingResult: BillingResult) {
|
||||
if (billingResult.responseCode == BillingClient.BillingResponseCode.OK) {
|
||||
billingClientState = BillingClientState.READY
|
||||
billingClient.queryPurchasesAsync(
|
||||
BillingClient.SkuType.SUBS,
|
||||
this@PurchaseHandler
|
||||
)
|
||||
billingClient.queryPurchasesAsync(
|
||||
BillingClient.SkuType.INAPP,
|
||||
this@PurchaseHandler
|
||||
)
|
||||
queryPurchases()
|
||||
} else {
|
||||
billingClientState = BillingClientState.UNAVAILABLE
|
||||
}
|
||||
|
|
@ -126,6 +119,19 @@ open class PurchaseHandler(
|
|||
billingClient.endConnection()
|
||||
}
|
||||
|
||||
fun queryPurchases(){
|
||||
if (billingClientState == BillingClientState.READY){
|
||||
billingClient.queryPurchasesAsync(
|
||||
BillingClient.SkuType.SUBS,
|
||||
this@PurchaseHandler
|
||||
)
|
||||
billingClient.queryPurchasesAsync(
|
||||
BillingClient.SkuType.INAPP,
|
||||
this@PurchaseHandler
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
suspend fun getAllGemSKUs(): List<SkuDetails> =
|
||||
getSKUs(BillingClient.SkuType.INAPP, PurchaseTypes.allGemTypes)
|
||||
|
||||
|
|
|
|||
|
|
@ -91,6 +91,7 @@ class GemsPurchaseFragment : BaseFragment<FragmentGemPurchaseBinding>() {
|
|||
|
||||
override fun onResume() {
|
||||
super.onResume()
|
||||
purchaseHandler.queryPurchases()
|
||||
loadInventory()
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -102,6 +102,7 @@ class SubscriptionFragment : BaseFragment<FragmentSubscriptionBinding>() {
|
|||
|
||||
override fun onResume() {
|
||||
super.onResume()
|
||||
purchaseHandler.queryPurchases()
|
||||
refresh()
|
||||
loadInventory()
|
||||
}
|
||||
|
|
|
|||
|
|
@ -49,6 +49,8 @@ class InsufficientGemsDialog(context: Context, var gemPrice: Int) : Insufficient
|
|||
addCloseButton()
|
||||
}
|
||||
|
||||
|
||||
|
||||
override fun onAttachedToWindow() {
|
||||
super.onAttachedToWindow()
|
||||
getActivity()?.let { activity ->
|
||||
|
|
|
|||
Loading…
Reference in a new issue