fixes a crash when trying to share via Tusky while not logged in
This commit is contained in:
parent
ba46e90140
commit
6dd8c7a3ec
1 changed files with 8 additions and 4 deletions
|
@ -55,9 +55,6 @@ public abstract class BaseActivity extends AppCompatActivity {
|
||||||
protected void onCreate(@Nullable Bundle savedInstanceState) {
|
protected void onCreate(@Nullable Bundle savedInstanceState) {
|
||||||
super.onCreate(savedInstanceState);
|
super.onCreate(savedInstanceState);
|
||||||
|
|
||||||
redirectIfNotLoggedIn();
|
|
||||||
createMastodonApi();
|
|
||||||
|
|
||||||
SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(this);
|
SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(this);
|
||||||
|
|
||||||
/* There isn't presently a way to globally change the theme of a whole application at
|
/* 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);
|
getTheme().applyStyle(style, false);
|
||||||
|
|
||||||
|
if(redirectIfNotLoggedIn()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
createMastodonApi();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -152,13 +154,15 @@ public abstract class BaseActivity extends AppCompatActivity {
|
||||||
mastodonApi = retrofit.create(MastodonApi.class);
|
mastodonApi = retrofit.create(MastodonApi.class);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void redirectIfNotLoggedIn() {
|
protected boolean redirectIfNotLoggedIn() {
|
||||||
if (TuskyApplication.getAccountManager().getActiveAccount() == null) {
|
if (TuskyApplication.getAccountManager().getActiveAccount() == null) {
|
||||||
Intent intent = new Intent(this, LoginActivity.class);
|
Intent intent = new Intent(this, LoginActivity.class);
|
||||||
intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_NEW_TASK);
|
intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_NEW_TASK);
|
||||||
startActivity(intent);
|
startActivity(intent);
|
||||||
finish();
|
finish();
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
Loading…
Reference in a new issue