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

This commit is contained in:
Conny Duck 2018-02-05 11:27:32 +01:00
parent ba46e90140
commit 6dd8c7a3ec

View file

@ -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