From ce4ebc52a6fd7e2084eb6b54f9147269329aa87b Mon Sep 17 00:00:00 2001 From: Ben Komalo Date: Thu, 6 Oct 2011 16:15:22 -0700 Subject: [PATCH] Ensure proper mailbox is highlighted. Bug: 5424565 Change-Id: I1436568aa1c7d7d2becce27ee068d88deb217496 --- .../email/activity/MailboxListFragment.java | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/src/com/android/email/activity/MailboxListFragment.java b/src/com/android/email/activity/MailboxListFragment.java index 80f825fbc..34001c8a9 100644 --- a/src/com/android/email/activity/MailboxListFragment.java +++ b/src/com/android/email/activity/MailboxListFragment.java @@ -552,7 +552,7 @@ public class MailboxListFragment extends ListFragment implements OnItemClickList Log.d(Logging.LOG_TAG, this + " restoreInstanceState"); } mParentMailboxId = savedInstanceState.getLong(BUNDLE_KEY_PARENT_MAILBOX_ID); - mHighlightedMailboxId = savedInstanceState.getLong(BUNDLE_KEY_HIGHLIGHTED_MAILBOX_ID); + mNextHighlightedMailboxId = savedInstanceState.getLong(BUNDLE_KEY_HIGHLIGHTED_MAILBOX_ID); mSavedListState = savedInstanceState.getParcelable(BUNDLE_LIST_STATE); } @@ -784,6 +784,8 @@ public class MailboxListFragment extends ListFragment implements OnItemClickList MailboxFragmentAdapter.CursorWithExtras c = (MailboxFragmentAdapter.CursorWithExtras) cursor; if ((c.mChildCount == 0) && !isRoot()) { + // Always swap out the cursor so we don't hold a reference to a stale one. + mListAdapter.swapCursor(cursor); navigateUp(); return; } @@ -804,15 +806,20 @@ public class MailboxListFragment extends ListFragment implements OnItemClickList // icon. mListAdapter.swapCursor(null); setListShown(false); + } else { mParentDetermined = true; // Okay now we're sure which mailbox is the parent. mListAdapter.swapCursor(cursor); setListShown(true); + // Restore the list state, so scroll position is restored - this has to happen + // prior to setting the checked/highlighted mailbox below. + lv.onRestoreInstanceState(listState); + // Update the highlighted mailbox if (mNextHighlightedMailboxId != Mailbox.NO_MAILBOX) { - mHighlightedMailboxId = mNextHighlightedMailboxId; + setHighlightedMailbox(mNextHighlightedMailboxId); mNextHighlightedMailboxId = Mailbox.NO_MAILBOX; } @@ -829,9 +836,6 @@ public class MailboxListFragment extends ListFragment implements OnItemClickList mDropTargetId = NO_DROP_TARGET; mDropTargetView = null; - // Restore the list state. - lv.onRestoreInstanceState(listState); - mIsFirstLoad = false; }