Fixing save state management for the contact list.
Interestingly enough, onRestoreSavedInstance is NOT called
during the onRestart() sequence!
Change-Id: I1b58f369c4ed03d3d778137d2e02162c047fc1e4
diff --git a/src/com/android/contacts/ContactsListActivity.java b/src/com/android/contacts/ContactsListActivity.java
index 18c3e26..26fb083 100644
--- a/src/com/android/contacts/ContactsListActivity.java
+++ b/src/com/android/contacts/ContactsListActivity.java
@@ -1951,9 +1951,6 @@
protected void onQueryComplete(Cursor cursor) {
mAdapter.changeCursor(cursor);
-
- // TODO make this triggered by the Loader
- mListFragment.completeRestoreInstanceState();
}
private CallOrSmsInitiator getCallOrSmsInitiator() {
@@ -1962,4 +1959,16 @@
}
return mCallOrSmsInitiator;
}
+
+ @Override
+ protected void onSaveInstanceState(Bundle outState) {
+ super.onSaveInstanceState(outState);
+ mListFragment.onSaveInstanceState(outState);
+ }
+
+ @Override
+ protected void onRestoreInstanceState(Bundle savedInstanceState) {
+ super.onRestoreInstanceState(savedInstanceState);
+ mListFragment.onRestoreInstanceState(savedInstanceState);
+ }
}
diff --git a/src/com/android/contacts/list/ContactEntryListFragment.java b/src/com/android/contacts/list/ContactEntryListFragment.java
index bff729c..6f133c4 100644
--- a/src/com/android/contacts/list/ContactEntryListFragment.java
+++ b/src/com/android/contacts/list/ContactEntryListFragment.java
@@ -184,6 +184,8 @@
mAdapter.changeCursor(data);
showCount(data);
+
+ completeRestoreInstanceState();
}
protected void reloadData() {
@@ -503,23 +505,23 @@
@Override
public void onSaveInstanceState(Bundle icicle) {
super.onSaveInstanceState(icicle);
- // Save list state in the bundle so we can restore it after the QueryHandler has run
if (mListView != null) {
- icicle.putParcelable(LIST_STATE_KEY, mListView.onSaveInstanceState());
+ mListState = mListView.onSaveInstanceState();
+ icicle.putParcelable(LIST_STATE_KEY, mListState);
}
}
@Override
public void onRestoreInstanceState(Bundle icicle) {
super.onRestoreInstanceState(icicle);
- // Retrieve list state. This will be applied after the QueryHandler has run
+ // Retrieve list state. This will be applied in onLoadFinished
mListState = icicle.getParcelable(LIST_STATE_KEY);
}
/**
* Restore the list state after the adapter is populated.
*/
- public void completeRestoreInstanceState() {
+ private void completeRestoreInstanceState() {
if (mListState != null) {
mListView.onRestoreInstanceState(mListState);
mListState = null;