Fix issue #645 - Open with another account when there are only two accounts
This commit is contained in:
parent
7a3c34b749
commit
de4faeadbc
|
@ -1805,7 +1805,7 @@ public class StatusAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder>
|
|||
BaseMainActivity.currentToken = account.token;
|
||||
BaseMainActivity.currentUserID = account.user_id;
|
||||
BaseMainActivity.currentInstance = account.instance;
|
||||
MainActivity.currentAccount = account;
|
||||
currentAccount = account;
|
||||
SharedPreferences.Editor editor = sharedpreferences.edit();
|
||||
editor.putString(PREF_USER_TOKEN, account.token);
|
||||
editor.putString(PREF_USER_INSTANCE, account.instance);
|
||||
|
@ -1822,6 +1822,28 @@ public class StatusAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder>
|
|||
builderSingle.show();
|
||||
};
|
||||
mainHandler.post(myRunnable);
|
||||
} else if (accounts.size() == 1) {
|
||||
Handler mainHandler = new Handler(Looper.getMainLooper());
|
||||
Runnable myRunnable = () -> {
|
||||
BaseAccount account = accounts.get(0);
|
||||
Toasty.info(context, context.getString(R.string.toast_account_changed, "@" + account.mastodon_account.acct + "@" + account.instance), Toasty.LENGTH_LONG).show();
|
||||
BaseMainActivity.currentToken = account.token;
|
||||
BaseMainActivity.currentUserID = account.user_id;
|
||||
BaseMainActivity.currentInstance = account.instance;
|
||||
currentAccount = account;
|
||||
SharedPreferences.Editor editor = sharedpreferences.edit();
|
||||
editor.putString(PREF_USER_TOKEN, account.token);
|
||||
editor.putString(PREF_USER_INSTANCE, account.instance);
|
||||
editor.putString(PREF_USER_ID, account.user_id);
|
||||
editor.commit();
|
||||
Intent mainActivity = new Intent(context, MainActivity.class);
|
||||
mainActivity.putExtra(Helper.INTENT_ACTION, Helper.OPEN_WITH_ANOTHER_ACCOUNT);
|
||||
mainActivity.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TASK);
|
||||
mainActivity.putExtra(Helper.PREF_MESSAGE_URL, statusToDeal.url);
|
||||
context.startActivity(mainActivity);
|
||||
((Activity) context).finish();
|
||||
};
|
||||
mainHandler.post(myRunnable);
|
||||
}
|
||||
|
||||
} catch (DBException e) {
|
||||
|
|
Loading…
Reference in New Issue