From 0b3bee0d15e53de52dedce4e6627f5f7267a7673 Mon Sep 17 00:00:00 2001 From: Konrad Pozniak Date: Mon, 3 Sep 2018 20:16:12 +0200 Subject: [PATCH] fix account switching when offline/error (#830) --- .../com/keylesspalace/tusky/MainActivity.java | 21 +++++++++++-------- 1 file changed, 12 insertions(+), 9 deletions(-) diff --git a/app/src/main/java/com/keylesspalace/tusky/MainActivity.java b/app/src/main/java/com/keylesspalace/tusky/MainActivity.java index 3a062fcf..dcbce519 100644 --- a/app/src/main/java/com/keylesspalace/tusky/MainActivity.java +++ b/app/src/main/java/com/keylesspalace/tusky/MainActivity.java @@ -420,7 +420,7 @@ public final class MainActivity extends BottomSheetActivity implements ActionBut Intent intent = new Intent(this, MainActivity.class); intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TASK); - startActivityWithSlideInAnimation(intent); + startActivity(intent); finishWithoutSlideOutAnimation(); overridePendingTransition(R.anim.explode, R.anim.explode); @@ -510,21 +510,15 @@ public final class MainActivity extends BottomSheetActivity implements ActionBut List allAccounts = accountManager.getAllAccountsOrderedByActive(); - // reuse the already existing "add account" item List profiles = new ArrayList<>(allAccounts.size()+1); - for (IProfile profile: headerResult.getProfiles()) { - if (profile.getIdentifier() == DRAWER_ITEM_ADD_ACCOUNT) { - profiles.add(profile); - break; - } - } for (AccountEntity acc : allAccounts) { CharSequence emojifiedName = CustomEmojiHelper.emojifyString(acc.getDisplayName(), acc.getEmojis(), headerResult.getView()); emojifiedName = EmojiCompat.get().process(emojifiedName); - profiles.add(0, + profiles.add( new ProfileDrawerItem() + .withSetSelected(acc.isActive()) .withName(emojifiedName) .withIcon(acc.getProfilePictureUrl()) .withNameShown(true) @@ -532,6 +526,15 @@ public final class MainActivity extends BottomSheetActivity implements ActionBut .withEmail(acc.getFullName())); } + + // reuse the already existing "add account" item + for (IProfile profile: headerResult.getProfiles()) { + if (profile.getIdentifier() == DRAWER_ITEM_ADD_ACCOUNT) { + profiles.add(profile); + break; + } + } + headerResult.clear(); headerResult.setProfiles(profiles); }