diff --git a/src/com/fsck/k9/fragment/MessageListFragment.java b/src/com/fsck/k9/fragment/MessageListFragment.java index 54c32fef5..7a3b8d29c 100644 --- a/src/com/fsck/k9/fragment/MessageListFragment.java +++ b/src/com/fsck/k9/fragment/MessageListFragment.java @@ -804,9 +804,9 @@ public class MessageListFragment extends SherlockFragment implements OnItemClick super.onSaveInstanceState(outState); saveSelectedMessages(outState); + saveListState(outState); outState.putBoolean(STATE_REMOTE_SEARCH_PERFORMED, mRemoteSearchPerformed); - outState.putParcelable(STATE_MESSAGE_LIST, mListView.onSaveInstanceState()); outState.putParcelable(STATE_ACTIVE_MESSAGE, mActiveMessage); } @@ -849,6 +849,15 @@ public class MessageListFragment extends SherlockFragment implements OnItemClick } } + private void saveListState(Bundle outState) { + if (mSavedListState != null) { + // The previously saved state was never restored, so just use that. + outState.putParcelable(STATE_MESSAGE_LIST, mSavedListState); + } else if (mListView != null) { + outState.putParcelable(STATE_MESSAGE_LIST, mListView.onSaveInstanceState()); + } + } + private void initializeSortSettings() { if (mSingleAccountMode) { mSortType = mAccount.getSortType();