Skip to content
This repository has been archived by the owner on Jun 20, 2021. It is now read-only.

Commit

Permalink
Fix crash when back is pressed on setup
Browse files Browse the repository at this point in the history
  • Loading branch information
ratan12 committed Jan 16, 2016
1 parent 98194e7 commit aba767a
Showing 1 changed file with 22 additions and 20 deletions.
42 changes: 22 additions & 20 deletions Atarashii/src/net/somethingdreadful/MAL/FirstTimeInit.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;
Expand Down Expand Up @@ -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)
Expand Down

0 comments on commit aba767a

Please sign in to comment.