aboutsummaryrefslogtreecommitdiff
path: root/app/src/main/kotlin/com/pitchedapps
diff options
context:
space:
mode:
Diffstat (limited to 'app/src/main/kotlin/com/pitchedapps')
-rw-r--r--app/src/main/kotlin/com/pitchedapps/frost/SettingsActivity.kt8
-rw-r--r--app/src/main/kotlin/com/pitchedapps/frost/utils/iab/IAB.kt9
2 files changed, 7 insertions, 10 deletions
diff --git a/app/src/main/kotlin/com/pitchedapps/frost/SettingsActivity.kt b/app/src/main/kotlin/com/pitchedapps/frost/SettingsActivity.kt
index e67fc949..66c541ed 100644
--- a/app/src/main/kotlin/com/pitchedapps/frost/SettingsActivity.kt
+++ b/app/src/main/kotlin/com/pitchedapps/frost/SettingsActivity.kt
@@ -2,7 +2,6 @@ package com.pitchedapps.frost
import android.content.Intent
import android.os.Bundle
-import android.support.design.widget.Snackbar
import android.view.Menu
import android.view.MenuItem
import ca.allanwang.kau.changelog.showChangelog
@@ -129,10 +128,7 @@ class SettingsActivity : KPrefActivity(), IabBroadcastReceiver.IabBroadcastListe
R.id.action_email -> materialDialogThemed {
title(R.string.subject)
items(Support.values().map { string(it.title) })
- itemsCallback {
- _, _, which, _ ->
- Support.values()[which].sendEmail(this@SettingsActivity)
- }
+ itemsCallback { _, _, which, _ -> Support.values()[which].sendEmail(this@SettingsActivity) }
}
R.id.action_changelog -> showChangelog(R.xml.changelog, Prefs.textColor) { theme() }
else -> return super.onOptionsItemSelected(item)
@@ -141,7 +137,7 @@ class SettingsActivity : KPrefActivity(), IabBroadcastReceiver.IabBroadcastListe
}
override fun onDestroy() {
- if (!IAB.isInProgress) IAB.dispose()
+ IAB.dispose()
super.onDestroy()
}
} \ No newline at end of file
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