From 7df0ec50f2a7897545727338f51f8623c159e75f Mon Sep 17 00:00:00 2001 From: M66B Date: Mon, 2 Nov 2015 19:47:09 +0100 Subject: [PATCH] IAB improvements --- .../java/eu/faircode/netguard/ActivityMain.java | 16 +++++----------- 1 file changed, 5 insertions(+), 11 deletions(-) diff --git a/app/src/main/java/eu/faircode/netguard/ActivityMain.java b/app/src/main/java/eu/faircode/netguard/ActivityMain.java index fc381a28..a019b33c 100644 --- a/app/src/main/java/eu/faircode/netguard/ActivityMain.java +++ b/app/src/main/java/eu/faircode/netguard/ActivityMain.java @@ -528,9 +528,7 @@ public class ActivityMain extends AppCompatActivity implements SharedPreferences @Override protected void onPostExecute(Object result) { try { - if (result instanceof Throwable) - throw (Throwable) result; - else if (result != null && (Boolean) result && IABService != null) { + if (result instanceof Boolean && (Boolean) result && IABService != null) { IntentSender sender = IABgetIntent(SKU_DONATE, IABService, ActivityMain.this); startIntentSenderForResult(sender, REQUEST_IAB, new Intent(), 0, 0, 0); } else { @@ -571,7 +569,7 @@ public class ActivityMain extends AppCompatActivity implements SharedPreferences .create(); dialog.show(); - // Validate IAB + // Check if IAB purchased new AsyncTask() { @Override protected Object doInBackground(Object... objects) { @@ -585,13 +583,9 @@ public class ActivityMain extends AppCompatActivity implements SharedPreferences @Override protected void onPostExecute(Object result) { - if (result instanceof Throwable) - Toast.makeText(ActivityMain.this, result.toString(), Toast.LENGTH_LONG).show(); - else { - boolean purchased = (result != null && (Boolean) result); - btnDonate.setVisibility(purchased ? View.GONE : View.VISIBLE); - tvThanks.setVisibility(purchased ? View.VISIBLE : View.GONE); - } + boolean purchased = (result instanceof Boolean && (Boolean) result); + btnDonate.setVisibility(purchased ? View.GONE : View.VISIBLE); + tvThanks.setVisibility(purchased ? View.VISIBLE : View.GONE); } }.execute(); }