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

Commit 1925eb3b authored by Zoey Chen's avatar Zoey Chen Committed by Android (Google) Code Review
Browse files

Merge "[Settings] Do not setup UI twice, only update UI when the search is changed" into main

parents bfc455c7 27dc4b7b
Loading
Loading
Loading
Loading
+7 −0
Original line number Diff line number Diff line
@@ -109,6 +109,7 @@ public class RegionAndNumberingSystemPickerFragment extends DashboardFragment im
    private String mPackageName;
    @Nullable
    private CharSequence mPreviousSearch = null;
    private boolean mIsSearchChanged;

    @Override
    public void onCreate(@NonNull Bundle icicle) {
@@ -215,6 +216,7 @@ public class RegionAndNumberingSystemPickerFragment extends DashboardFragment im
                results.values = mOriginalLocaleInfos;
                results.count = mOriginalLocaleInfos.size();
            } else {
                mIsSearchChanged = true;
                // TODO: decide if we should use the string's locale
                List<LocaleStore.LocaleInfo> newList = new ArrayList<>(mOriginalLocaleInfos);
                List<LocaleStore.LocaleInfo> suggestedList = TextUtils.isEmpty(mPackageName)
@@ -247,6 +249,11 @@ public class RegionAndNumberingSystemPickerFragment extends DashboardFragment im

        @Override
        protected void publishResults(CharSequence constraint, FilterResults results) {
            if (!mIsSearchChanged) {
                Log.d(TAG, "Do not update UI if search is not changed.");
                return;
            }

            mLocaleOptions = (ArrayList<LocaleStore.LocaleInfo>) results.values;
            // TODO: Need to scroll to first preference when searching.
            if (mRecyclerView != null) {
+7 −0
Original line number Diff line number Diff line
@@ -91,6 +91,7 @@ public class SystemLocalePickerFragment extends DashboardFragment implements
    private RecyclerView mRecyclerView;
    private Activity mActivity;
    private boolean mExpandSearch;
    private boolean mIsSearchChanged;
    private CharSequence mPreviousSearch = null;

    @Override
@@ -202,6 +203,7 @@ public class SystemLocalePickerFragment extends DashboardFragment implements
                results.values = mOriginalLocaleInfos;
                results.count = mOriginalLocaleInfos.size();
            } else {
                mIsSearchChanged = true;
                // TODO: decide if we should use the string's locale
                Locale locale = Locale.getDefault();
                String prefixString = LocaleHelper.normalizeForSearch(prefix.toString(), locale);
@@ -237,6 +239,11 @@ public class SystemLocalePickerFragment extends DashboardFragment implements
                return;
            }

            if (!mIsSearchChanged) {
                Log.d(TAG, "Do not update UI if search is not changed.");
                return;
            }

            mLocaleOptions = (ArrayList<LocaleStore.LocaleInfo>) results.values;
            // Need to scroll to first preference when searching.
            if (mRecyclerView != null) {