From 1ab04587a990970faa3751faebf1bed88c12e6c0 Mon Sep 17 00:00:00 2001 From: cketti Date: Wed, 30 Jan 2013 22:30:19 +0100 Subject: [PATCH] Restore list state when recreating MessageListFragment --- src/com/fsck/k9/fragment/MessageListFragment.java | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/com/fsck/k9/fragment/MessageListFragment.java b/src/com/fsck/k9/fragment/MessageListFragment.java index dab65d1d4..12337ff90 100644 --- a/src/com/fsck/k9/fragment/MessageListFragment.java +++ b/src/com/fsck/k9/fragment/MessageListFragment.java @@ -312,6 +312,7 @@ public class MessageListFragment extends SherlockFragment implements OnItemClick private static final String STATE_SELECTED_MESSAGES = "selectedMessages"; private static final String STATE_REMOTE_SEARCH_PERFORMED = "remoteSearchPerformed"; + private static final String STATE_MESSAGE_LIST = "listState"; /** * Maps a {@link SortType} to a {@link Comparator} implementation. @@ -473,8 +474,11 @@ public class MessageListFragment extends SherlockFragment implements OnItemClick } public void restoreListPosition() { - android.os.Message msg = android.os.Message.obtain(this, ACTION_RESTORE_LIST_POSITION); - sendMessage(msg); + if (!hasMessages(ACTION_RESTORE_LIST_POSITION)) { + android.os.Message msg = android.os.Message.obtain(this, + ACTION_RESTORE_LIST_POSITION); + sendMessage(msg); + } } @Override @@ -776,6 +780,7 @@ public class MessageListFragment extends SherlockFragment implements OnItemClick saveSelectedMessages(outState); outState.putBoolean(STATE_REMOTE_SEARCH_PERFORMED, mRemoteSearchPerformed); + outState.putParcelable(STATE_MESSAGE_LIST, mListView.onSaveInstanceState()); } /** @@ -791,6 +796,7 @@ public class MessageListFragment extends SherlockFragment implements OnItemClick restoreSelectedMessages(savedInstanceState); mRemoteSearchPerformed = savedInstanceState.getBoolean(STATE_REMOTE_SEARCH_PERFORMED); + mSavedListState = savedInstanceState.getParcelable(STATE_MESSAGE_LIST); } /**