diff options
Diffstat (limited to 'app/src/main/kotlin/com/pitchedapps/frost/utils')
-rw-r--r-- | app/src/main/kotlin/com/pitchedapps/frost/utils/Utils.kt | 2 | ||||
-rw-r--r-- | app/src/main/kotlin/com/pitchedapps/frost/utils/iab/IAB.kt | 31 |
2 files changed, 17 insertions, 16 deletions
diff --git a/app/src/main/kotlin/com/pitchedapps/frost/utils/Utils.kt b/app/src/main/kotlin/com/pitchedapps/frost/utils/Utils.kt index 986f9565..eb346140 100644 --- a/app/src/main/kotlin/com/pitchedapps/frost/utils/Utils.kt +++ b/app/src/main/kotlin/com/pitchedapps/frost/utils/Utils.kt @@ -133,7 +133,7 @@ fun Context.scheduleNotifications(minutes: Long): Boolean { .setRequiredNetworkType(JobInfo.NETWORK_TYPE_ANY) //TODO add options val result = scheduler.schedule(builder.build()) if (result <= 0) { - L.e("Notification scheduler failed") + L.eThrow("Notification scheduler failed") return false } return true 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 11fa1c4b..5d0cdfa2 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 @@ -8,7 +8,6 @@ import com.crashlytics.android.answers.PurchaseEvent import com.pitchedapps.frost.BuildConfig import com.pitchedapps.frost.R import com.pitchedapps.frost.utils.* -import org.jetbrains.anko.doAsync /** * Created by Allan Wang on 2017-06-23. @@ -19,17 +18,15 @@ object IAB { fun setupAsync(context: Context) { if (!context.isFromGooglePlay) return - doAsync { - if (helper == null) { - try { - helper = IabHelper(context.applicationContext, PUBLIC_BILLING_KEY) - helper!!.startSetup { - result -> - if (!result.isSuccess) L.e("IAB Setup error: $result") - } - } catch (e: Exception) { - L.e("IAB error: ${e.message}") + if (helper == null) { + try { + helper = IabHelper(context.applicationContext, PUBLIC_BILLING_KEY) + helper!!.startSetup { + result -> + if (!result.isSuccess) L.eThrow("IAB Setup error: $result") } + } catch (e: Exception) { + L.e(e, "IAB error") } } } @@ -59,10 +56,13 @@ fun Activity.openPlayPurchase(key: String, code: Int) { frostAnswersCustom("PLAY_PURCHASE") { putCustomAttribute("Key", key) } - IAB.helper?.flagEndAsync() + IAB.helper?.flagEndAsync() ?: playStoreErrorDialog() IAB.helper?.queryInventoryAsync { - _, inv -> - if (inv == null) { + res, inv -> + if (res.isFailure) { + L.e("IAB error: ${res.message}") + playStoreErrorDialog() + } else if (inv == null) { playStoreErrorDialog() } else { val donation = inv.getSkuDetails(key) @@ -79,7 +79,7 @@ fun Activity.openPlayPurchase(key: String, code: Int) { .putItemId(key) .putSuccess(result.isSuccess)) } - } + } ?: playStoreErrorDialog() } } } @@ -91,4 +91,5 @@ private fun Context.playStoreErrorDialog() { content(R.string.play_store_billing_error) positiveText(R.string.kau_ok) } + L.eThrow("Play Store Error") }
\ No newline at end of file |