diff options
author | Allan Wang <me@allanwang.ca> | 2017-07-03 22:06:42 -0700 |
---|---|---|
committer | Allan Wang <me@allanwang.ca> | 2017-07-04 01:17:26 -0400 |
commit | 74ab377fdb14b09929d218836186507b60e0b306 (patch) | |
tree | 98f8dbf22a47b11ae6127afa093145fb0fad461c /app/src/main/kotlin/com/pitchedapps/frost/utils | |
parent | fe6162c7d1e60d473735d0a0f5e74084d300c06f (diff) | |
download | frost-74ab377fdb14b09929d218836186507b60e0b306.tar.gz frost-74ab377fdb14b09929d218836186507b60e0b306.tar.bz2 frost-74ab377fdb14b09929d218836186507b60e0b306.zip |
Finalize iab
Diffstat (limited to 'app/src/main/kotlin/com/pitchedapps/frost/utils')
-rw-r--r-- | app/src/main/kotlin/com/pitchedapps/frost/utils/iab/IAB.kt | 9 |
1 files changed, 5 insertions, 4 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 a15d0520..da735430 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 @@ -20,6 +20,9 @@ import com.pitchedapps.frost.utils.* * Make sure you call [IAB.dispose] once an operation is done to release the resources * Also make sure that it is called on the very LAST operation if there are a list of async calls. * Otherwise the helper will be prematurely disposed + * + * For the most part, billing is handled in the [SettingsActivity] and will be disposed when it is destroyed + * It may also be handled elsewhere when validating purchases, so those calls should dispose themselves */ object IAB { @@ -30,16 +33,14 @@ object IAB { * * [mustHavePlayStore] decides if dialogs should be shown if play store errors occur * - * */ operator fun invoke(activity: Activity, mustHavePlayStore: Boolean = true, onFailed: () -> Unit = {}, onStart: (helper: IabHelper) -> Unit) { with(activity) { - if (helper?.mDisposed ?: true) { + if (helper?.mDisposed ?: helper?.mDisposeAfterAsync ?: true) { helper = null L.d("IAB setup async") if (!isFrostPlay) { if (mustHavePlayStore) playStoreNotFound() - IAB.dispose() onFailed() return } @@ -183,6 +184,7 @@ fun Activity.openPlayPurchase(key: String, code: Int, onSuccess: (key: String) - if (result.isSuccess) { onSuccess(key) playStorePurchasedSuccessfully(key) + IAB.dispose() } frostAnswers { logPurchase(PurchaseEvent() @@ -190,7 +192,6 @@ fun Activity.openPlayPurchase(key: String, code: Int, onSuccess: (key: String) - .putCustomAttribute("result", result.message) .putSuccess(result.isSuccess)) } - IAB.dispose() } } }
\ No newline at end of file |