From d523caa61bb5595b9c7723d5807adbee9ec0a19c Mon Sep 17 00:00:00 2001 From: Danny Baumann Date: Sun, 10 Mar 2013 12:27:58 +0100 Subject: [PATCH] Also clear back stack when a new intent arrives. This should make sure there aren't any old fragment instances in that case. --- src/com/fsck/k9/activity/MessageList.java | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/src/com/fsck/k9/activity/MessageList.java b/src/com/fsck/k9/activity/MessageList.java index bef68a99f..65d9ac745 100644 --- a/src/com/fsck/k9/activity/MessageList.java +++ b/src/com/fsck/k9/activity/MessageList.java @@ -163,6 +163,7 @@ public class MessageList extends K9FragmentActivity implements MessageListFragme private MessageListFragment mMessageListFragment; private MessageViewFragment mMessageViewFragment; + private int mFirstBackStackId = -1; private Account mAccount; private String mFolderName; @@ -238,6 +239,11 @@ public class MessageList extends K9FragmentActivity implements MessageListFragme setIntent(intent); + if (mFirstBackStackId >= 0) { + getSupportFragmentManager().popBackStackImmediate(mFirstBackStackId, + FragmentManager.POP_BACK_STACK_INCLUSIVE); + mFirstBackStackId = -1; + } removeMessageListFragment(); removeMessageViewFragment(); @@ -1159,11 +1165,7 @@ public class MessageList extends K9FragmentActivity implements MessageListFragme @Override public void onBackStackChanged() { - FragmentManager fragmentManager = getSupportFragmentManager(); - mMessageListFragment = (MessageListFragment) fragmentManager.findFragmentById( - R.id.message_list_container); - mMessageViewFragment = (MessageViewFragment) fragmentManager.findFragmentById( - R.id.message_view_container); + findFragments(); if (mDisplayMode == DisplayMode.SPLIT_VIEW) { showMessageViewPlaceHolder(); @@ -1213,7 +1215,11 @@ public class MessageList extends K9FragmentActivity implements MessageListFragme ft.addToBackStack(null); mMessageListFragment = fragment; - ft.commit(); + + int transactionId = ft.commit(); + if (transactionId >= 0 && mFirstBackStackId < 0) { + mFirstBackStackId = transactionId; + } } @Override