Fix switch account toast when opening a notification

Closes #100
This commit is contained in:
Balazs Toldi 2023-08-19 16:36:22 +02:00
parent bf1036c919
commit deaa4e596d
No known key found for this signature in database
GPG Key ID: 6C7D440036F99D58

View File

@ -181,6 +181,8 @@ public class ViewPostDetailActivity extends BaseActivity implements SortTypeSele
private SectionsPagerAdapter sectionsPagerAdapter;
private String mAccessToken;
private String mAccountName;
private String mAccountQalifiedName;
private long postFragmentId;
private int postListPosition;
private int orientation;
@ -269,6 +271,7 @@ public class ViewPostDetailActivity extends BaseActivity implements SortTypeSele
mAccessToken = mCurrentAccountSharedPreferences.getString(SharedPreferencesUtils.ACCESS_TOKEN, null);
mAccountName = mCurrentAccountSharedPreferences.getString(SharedPreferencesUtils.ACCOUNT_NAME, null);
mAccountQalifiedName = mCurrentAccountSharedPreferences.getString(SharedPreferencesUtils.ACCOUNT_QUALIFIED_NAME, null);
mVolumeKeysNavigateComments = mSharedPreferences.getBoolean(SharedPreferencesUtils.VOLUME_KEYS_NAVIGATE_COMMENTS, false);
@ -353,8 +356,8 @@ public class ViewPostDetailActivity extends BaseActivity implements SortTypeSele
private void checkNewAccountAndBindView(Bundle savedInstanceState) {
if (mNewAccountName != null) {
if (mAccountName == null || !mAccountName.equals(mNewAccountName)) {
SwitchAccount.switchAccount(mRedditDataRoomDatabase,mRetrofit, mCurrentAccountSharedPreferences,
if (mAccountName == null || !mAccountQalifiedName.equals(mNewAccountName)) {
SwitchAccount.switchAccount(mRedditDataRoomDatabase, mRetrofit, mCurrentAccountSharedPreferences,
mExecutor, new Handler(), mNewAccountName, newAccount -> {
EventBus.getDefault().post(new SwitchAccountEvent(getClass().getName()));
Toast.makeText(this, R.string.account_switched, Toast.LENGTH_SHORT).show();