From aba767a93143c495afa3b90b45a7b8494102c305 Mon Sep 17 00:00:00 2001 From: ratan12 Date: Sat, 16 Jan 2016 15:41:25 +0100 Subject: [PATCH] Fix crash when back is pressed on setup --- .../somethingdreadful/MAL/FirstTimeInit.java | 42 ++++++++++--------- 1 file changed, 22 insertions(+), 20 deletions(-) diff --git a/Atarashii/src/net/somethingdreadful/MAL/FirstTimeInit.java b/Atarashii/src/net/somethingdreadful/MAL/FirstTimeInit.java index 030b8df2..1af1f449 100644 --- a/Atarashii/src/net/somethingdreadful/MAL/FirstTimeInit.java +++ b/Atarashii/src/net/somethingdreadful/MAL/FirstTimeInit.java @@ -7,6 +7,7 @@ import android.os.AsyncTask; import android.os.Bundle; import android.support.v7.app.AppCompatActivity; +import android.util.Log; import android.view.MenuItem; import android.view.View; import android.view.View.OnClickListener; @@ -18,6 +19,8 @@ import android.widget.TextView; import android.widget.ViewFlipper; +import com.crashlytics.android.Crashlytics; + import net.somethingdreadful.MAL.account.AccountService; import net.somethingdreadful.MAL.api.ALApi; import net.somethingdreadful.MAL.api.MALApi; @@ -116,29 +119,28 @@ public boolean onOptionsItemSelected(MenuItem item) { @Override public void onAuthenticationCheckFinished(boolean result) { - if (result) { - Theme.setCrashData("site", AccountService.accountType.toString()); - PrefManager.setForceSync(true); - PrefManager.commitChanges(); - dialog.dismiss(); - Intent goHome = new Intent(context, Home.class); - startActivity(goHome); - finish(); - } else if (!isDestroyed()) { - dialog.dismiss(); - if (MALApi.isNetworkAvailable(this)) - Theme.Snackbar(this, R.string.toast_error_VerifyProblem); - else - Theme.Snackbar(this, R.string.toast_error_noConnectivity); + try { + if (result) { + Theme.setCrashData("site", AccountService.accountType.toString()); + PrefManager.setForceSync(true); + PrefManager.commitChanges(); + dialog.dismiss(); + Intent goHome = new Intent(context, Home.class); + startActivity(goHome); + finish(); + } else { + dialog.dismiss(); + if (MALApi.isNetworkAvailable(this)) + Theme.Snackbar(this, R.string.toast_error_VerifyProblem); + else + Theme.Snackbar(this, R.string.toast_error_noConnectivity); + } + } catch (Exception e) { + Crashlytics.log(Log.ERROR, "MALX", "FirstTimeInit.onAuthenticationCheckFinished(): " + e.getMessage()); + Crashlytics.logException(e); } } - @Override - protected void onDestroy() { - dialog.dismiss(); - super.onDestroy(); - } - @Override public void onBackPressed() { if (viewFlipper.getDisplayedChild() == 1 || viewFlipper.getDisplayedChild() == 2)