From a42519030892ede729fc37ce6cbc93bb1d80989c Mon Sep 17 00:00:00 2001 From: Allan Wang Date: Thu, 29 Jun 2017 23:43:36 -0700 Subject: Add log throws --- .../kotlin/com/pitchedapps/frost/LoginActivity.kt | 2 +- .../kotlin/com/pitchedapps/frost/MainActivity.kt | 1 - .../pitchedapps/frost/facebook/UsernameFetcher.kt | 2 +- .../kotlin/com/pitchedapps/frost/utils/Utils.kt | 2 +- .../kotlin/com/pitchedapps/frost/utils/iab/IAB.kt | 31 +++++++++++----------- 5 files changed, 19 insertions(+), 19 deletions(-) (limited to 'app/src') diff --git a/app/src/main/kotlin/com/pitchedapps/frost/LoginActivity.kt b/app/src/main/kotlin/com/pitchedapps/frost/LoginActivity.kt index fdb918cc..cd6c2255 100644 --- a/app/src/main/kotlin/com/pitchedapps/frost/LoginActivity.kt +++ b/app/src/main/kotlin/com/pitchedapps/frost/LoginActivity.kt @@ -86,7 +86,7 @@ class LoginActivity : BaseActivity() { .observeOn(AndroidSchedulers.mainThread()).subscribe { (foundImage, name) -> refresh = false - if (!foundImage) L.e("Could not get profile photo; Invalid userId?\n\t$cookie") + if (!foundImage) L.eThrow("Could not get profile photo; Invalid userId?\n\t$cookie") textview.text = String.format(getString(R.string.welcome), name) textview.fadeIn() frostAnswers { diff --git a/app/src/main/kotlin/com/pitchedapps/frost/MainActivity.kt b/app/src/main/kotlin/com/pitchedapps/frost/MainActivity.kt index 02191730..d8230159 100644 --- a/app/src/main/kotlin/com/pitchedapps/frost/MainActivity.kt +++ b/app/src/main/kotlin/com/pitchedapps/frost/MainActivity.kt @@ -346,7 +346,6 @@ class MainActivity : BaseActivity(), FrostWebViewSearch.SearchContract { searchOverlayDispose() menu.findItem(R.id.action_search).setOnMenuItemClickListener { _ -> launchWebOverlay(FbTab.SEARCH.url); true } } - KL.e("SearchView ${searchView == null} HID ${hiddenSearchView == null}") return true } diff --git a/app/src/main/kotlin/com/pitchedapps/frost/facebook/UsernameFetcher.kt b/app/src/main/kotlin/com/pitchedapps/frost/facebook/UsernameFetcher.kt index 5bc58fa9..cbb6222a 100644 --- a/app/src/main/kotlin/com/pitchedapps/frost/facebook/UsernameFetcher.kt +++ b/app/src/main/kotlin/com/pitchedapps/frost/facebook/UsernameFetcher.kt @@ -21,7 +21,7 @@ object UsernameFetcher { .get().title() L.d("User name found: $name") } catch (e: Exception) { - L.e("User name fetching failed: ${e.message}") + L.e(e, "User name fetching failed") } finally { data.name = name saveFbCookie(data) 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 -- cgit v1.2.3