diff options
author | Allan Wang <me@allanwang.ca> | 2017-06-30 22:21:42 -0700 |
---|---|---|
committer | Allan Wang <me@allanwang.ca> | 2017-06-30 22:21:42 -0700 |
commit | fb4f71ef83d1bfbd3ae89701dc17f6ae31a35eb7 (patch) | |
tree | 00db493ae5cd51595a9d7f34ebf0d62dcd2c09d7 /app/src/main/kotlin/com/pitchedapps/frost/utils/iab/IAB.kt | |
parent | cf2a648e61290fe36453a56371c0d39e9edff8ff (diff) | |
download | frost-fb4f71ef83d1bfbd3ae89701dc17f6ae31a35eb7.tar.gz frost-fb4f71ef83d1bfbd3ae89701dc17f6ae31a35eb7.tar.bz2 frost-fb4f71ef83d1bfbd3ae89701dc17f6ae31a35eb7.zip |
Disable verbose logging on restart
Diffstat (limited to 'app/src/main/kotlin/com/pitchedapps/frost/utils/iab/IAB.kt')
-rw-r--r-- | app/src/main/kotlin/com/pitchedapps/frost/utils/iab/IAB.kt | 39 |
1 files changed, 22 insertions, 17 deletions
diff --git a/app/src/main/kotlin/com/pitchedapps/frost/utils/iab/IAB.kt b/app/src/main/kotlin/com/pitchedapps/frost/utils/iab/IAB.kt index 0fd10c5b..431ba0b6 100644 --- a/app/src/main/kotlin/com/pitchedapps/frost/utils/iab/IAB.kt +++ b/app/src/main/kotlin/com/pitchedapps/frost/utils/iab/IAB.kt @@ -22,6 +22,7 @@ object IAB { if (!activity.isFromGooglePlay && !BuildConfig.DEBUG) return L.d("IAB not from google play") try { helper = IabHelper(activity.applicationContext, PUBLIC_BILLING_KEY) + helper!!.enableDebugLogging(BuildConfig.DEBUG, "Frost:") helper!!.startSetup { result -> L.d("IAB result ${result.message}") @@ -63,24 +64,28 @@ fun Activity.openPlayPurchase(key: String, code: Int) { L.d("IAB flag end async") IAB.helper?.flagEndAsync() ?: return playStoreGenericError("Null flag end async") L.d("IAB query inv async") - IAB.helper!!.queryInventoryAsync { - res, inv -> - if (res.isFailure) return@queryInventoryAsync playStoreGenericError("Query res error") - if (inv == null) return@queryInventoryAsync playStoreGenericError("Empty inventory") - L.d("IAB: inventory ${inv.allOwnedSkus}") - val donation = inv.getSkuDetails(key) ?: return@queryInventoryAsync playStoreGenericError("Donation null") - IAB.helper!!.launchPurchaseFlow(this@openPlayPurchase, donation.sku, code) { - result, _ -> - if (result.isSuccess) materialDialogThemed { - title(R.string.play_thank_you) - content(R.string.play_purchased_pro) - positiveText(R.string.kau_ok) - } else playStoreGenericError("Result: ${result.message}") - frostAnswers { - logPurchase(PurchaseEvent() - .putItemId(key) - .putSuccess(result.isSuccess)) + try { + IAB.helper!!.queryInventoryAsync { + res, inv -> + if (res.isFailure) return@queryInventoryAsync playStoreGenericError("Query res error") + if (inv == null) return@queryInventoryAsync playStoreGenericError("Empty inventory") + L.d("IAB: inventory ${inv.allOwnedSkus}") + val donation = inv.getSkuDetails(key) ?: return@queryInventoryAsync playStoreGenericError("Donation null") + IAB.helper!!.launchPurchaseFlow(this@openPlayPurchase, donation.sku, code) { + result, _ -> + if (result.isSuccess) materialDialogThemed { + title(R.string.play_thank_you) + content(R.string.play_purchased_pro) + positiveText(R.string.kau_ok) + } else playStoreGenericError("Result: ${result.message}") + frostAnswers { + logPurchase(PurchaseEvent() + .putItemId(key) + .putSuccess(result.isSuccess)) + } } } + } catch(e: IabHelper.IabAsyncInProgressException) { + L.e(e, "IAB query dup") } }
\ No newline at end of file |