Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit ad8fefe9 authored by Makoto Onuki's avatar Makoto Onuki
Browse files

[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
parent 4254f97e
Loading
Loading
Loading
Loading
+14 −1
Original line number Diff line number Diff line
@@ -55,6 +55,9 @@ public class PhoneNumberPickerFragment extends ContactEntryListFragment<ContactE

    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 {
@@ -203,6 +206,12 @@ public class PhoneNumberPickerFragment extends ContactEntryListFragment<ContactE
        }
    }

    @Override
    protected void startLoading() {
        mLoaderStarted = true;
        super.startLoading();
    }

    @Override
    protected ContactEntryListAdapter createListAdapter() {
        if (!isLegacyCompatibilityMode()) {
@@ -272,7 +281,11 @@ public class PhoneNumberPickerFragment extends ContactEntryListFragment<ContactE
            ContactListFilter.storeToPreferences(mPrefs, mFilter);
        }

        // 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();
    }
}