mirror of
https://github.com/sudoxnym/habitica-android.git
synced 2026-05-22 05:38:55 +00:00
Merge pull request #1747 from Hafizzle/Fixes#1637
Fixes#1637 - Fix users unable to purchase gems because "you already own this item"
This commit is contained in:
commit
9b5ff2b1e8
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