fixes a crash when trying to share via Tusky while not logged in

main
Conny Duck 6 years ago
parent 4434d8828a
commit 94f018b578
  1. 12
      app/src/main/java/com/keylesspalace/tusky/BaseActivity.java

@ -55,9 +55,6 @@ public abstract class BaseActivity extends AppCompatActivity {
protected void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
redirectIfNotLoggedIn();
createMastodonApi();
SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(this);
/* There isn't presently a way to globally change the theme of a whole application at
@ -82,6 +79,11 @@ public abstract class BaseActivity extends AppCompatActivity {
}
getTheme().applyStyle(style, false);
if(redirectIfNotLoggedIn()) {
return;
}
createMastodonApi();
}
@Override
@ -152,13 +154,15 @@ public abstract class BaseActivity extends AppCompatActivity {
mastodonApi = retrofit.create(MastodonApi.class);
}
protected void redirectIfNotLoggedIn() {
protected boolean redirectIfNotLoggedIn() {
if (TuskyApplication.getAccountManager().getActiveAccount() == null) {
Intent intent = new Intent(this, LoginActivity.class);
intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_NEW_TASK);
startActivity(intent);
finish();
return true;
}
return false;
}
@Override

Loading…
Cancel
Save