Merge "Manually restore list view state."
This commit is contained in:
commit
63a206ea56
@ -20,7 +20,6 @@ import com.android.email.Controller;
|
|||||||
import com.android.email.Email;
|
import com.android.email.Email;
|
||||||
import com.android.email.R;
|
import com.android.email.R;
|
||||||
import com.android.email.RefreshManager;
|
import com.android.email.RefreshManager;
|
||||||
import com.android.email.activity.MailboxListFragment.Callback;
|
|
||||||
import com.android.email.provider.EmailProvider;
|
import com.android.email.provider.EmailProvider;
|
||||||
import com.android.emailcommon.Logging;
|
import com.android.emailcommon.Logging;
|
||||||
import com.android.emailcommon.provider.EmailContent.Account;
|
import com.android.emailcommon.provider.EmailContent.Account;
|
||||||
@ -811,6 +810,16 @@ public class MailboxListFragment extends ListFragment implements OnItemClickList
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Save list view state (primarily scroll position)
|
||||||
|
final ListView lv = getListView();
|
||||||
|
final Parcelable listState;
|
||||||
|
if (mSavedListState != null) {
|
||||||
|
listState = mSavedListState;
|
||||||
|
mSavedListState = null;
|
||||||
|
} else {
|
||||||
|
listState = lv.onSaveInstanceState();
|
||||||
|
}
|
||||||
|
|
||||||
if (cursor.getCount() == 0) {
|
if (cursor.getCount() == 0) {
|
||||||
// There's no row -- call setListShown(false) to make ListFragment show progress
|
// There's no row -- call setListShown(false) to make ListFragment show progress
|
||||||
// icon.
|
// icon.
|
||||||
@ -840,12 +849,8 @@ public class MailboxListFragment extends ListFragment implements OnItemClickList
|
|||||||
mDropTargetId = NO_DROP_TARGET;
|
mDropTargetId = NO_DROP_TARGET;
|
||||||
mDropTargetView = null;
|
mDropTargetView = null;
|
||||||
|
|
||||||
// Restore the state. Need to do it manually so that the position will be restored
|
// Restore the list state.
|
||||||
// even after orientation changes.
|
lv.onRestoreInstanceState(listState);
|
||||||
if (mSavedListState != null) {
|
|
||||||
getListView().onRestoreInstanceState(mSavedListState);
|
|
||||||
mSavedListState = null;
|
|
||||||
}
|
|
||||||
|
|
||||||
mIsFirstLoad = false;
|
mIsFirstLoad = false;
|
||||||
}
|
}
|
||||||
|
@ -1220,6 +1220,16 @@ public class MessageListFragment extends ListFragment
|
|||||||
// Suspend message notifications as long as we're resumed
|
// Suspend message notifications as long as we're resumed
|
||||||
adjustMessageNotification(false);
|
adjustMessageNotification(false);
|
||||||
|
|
||||||
|
// Save list view state (primarily scroll position)
|
||||||
|
final ListView lv = getListView();
|
||||||
|
final Parcelable listState;
|
||||||
|
if (mSavedListState != null) {
|
||||||
|
listState = mSavedListState;
|
||||||
|
mSavedListState = null;
|
||||||
|
} else {
|
||||||
|
listState = lv.onSaveInstanceState();
|
||||||
|
}
|
||||||
|
|
||||||
// If this is a search mailbox, set the query; otherwise, clear it
|
// If this is a search mailbox, set the query; otherwise, clear it
|
||||||
if (mMailbox != null && mMailbox.mType == Mailbox.TYPE_SEARCH) {
|
if (mMailbox != null && mMailbox.mType == Mailbox.TYPE_SEARCH) {
|
||||||
mListAdapter.setQuery(mMailbox.mDisplayName);
|
mListAdapter.setQuery(mMailbox.mDisplayName);
|
||||||
@ -1246,10 +1256,7 @@ public class MessageListFragment extends ListFragment
|
|||||||
|
|
||||||
// Restore the state -- this step has to be the last, because Some of the
|
// Restore the state -- this step has to be the last, because Some of the
|
||||||
// "post processing" seems to reset the scroll position.
|
// "post processing" seems to reset the scroll position.
|
||||||
if (mSavedListState != null) {
|
lv.onRestoreInstanceState(listState);
|
||||||
getListView().onRestoreInstanceState(mSavedListState);
|
|
||||||
mSavedListState = null;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Clear this for next reload triggered by content changed events.
|
// Clear this for next reload triggered by content changed events.
|
||||||
mIsFirstLoad = false;
|
mIsFirstLoad = false;
|
||||||
|
Loading…
Reference in New Issue
Block a user