[phone] Don't start search loader before it's ready
The setFilter() call in Dialtacs.onStart() indirectly started the loader,
but at this point the initialization in ContactEntryListFragment.onStart()
hasn't done yet, so we shouldn't the loader yet.
This caused the first loader to start with the wrong sort order if you have
"sort by last name" set.
Bug 5252597
Change-Id: Ia1efc7b097cb5c1068f0b2ebb6d61fb0c29f4302
diff --git a/src/com/android/contacts/list/PhoneNumberPickerFragment.java b/src/com/android/contacts/list/PhoneNumberPickerFragment.java
index 938d43a..015a364 100644
--- a/src/com/android/contacts/list/PhoneNumberPickerFragment.java
+++ b/src/com/android/contacts/list/PhoneNumberPickerFragment.java
@@ -55,6 +55,9 @@
private static final String KEY_FILTER = "filter";
+ /** true if the loader has started at least once. */
+ private boolean mLoaderStarted;
+
// A complete copy from DefaultContactBrowserListFragment
// TODO: should be able to share logic around filter header.
private class FilterHeaderClickListener implements OnClickListener {
@@ -204,6 +207,12 @@
}
@Override
+ protected void startLoading() {
+ mLoaderStarted = true;
+ super.startLoading();
+ }
+
+ @Override
protected ContactEntryListAdapter createListAdapter() {
if (!isLegacyCompatibilityMode()) {
PhoneNumberListAdapter adapter = new PhoneNumberListAdapter(getActivity());
@@ -272,7 +281,11 @@
ContactListFilter.storeToPreferences(mPrefs, mFilter);
}
- reloadData();
+ // This method can be called before {@link #onStart} where we start the loader. In that
+ // case we shouldn't start the loader yet, as we haven't done all initialization yet.
+ if (mLoaderStarted) {
+ reloadData();
+ }
updateFilterHeaderView();
}
}