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

Commit d3df5bdf authored by Calvin Pan's avatar Calvin Pan
Browse files

Fix fetching incorrect items after filtering

Using parent view's adapter to prevent getting incorrect item after
filtering the list.

Bug: 227447626
Bug: 227289977
Bug: 227279371

Test: By manual
Change-Id: Ic7dde57cdc0dd44adf803317f836131d578f044b
parent 2ca56df0
Loading
Loading
Loading
Loading
+3 −4
Original line number Original line Diff line number Diff line
@@ -264,10 +264,9 @@ public class LocalePickerWithRegion extends ListFragment implements SearchView.O
    }
    }


    @Override
    @Override
    public void onListItemClick(ListView l, View v, int position, long id) {
    public void onListItemClick(ListView parent, View v, int position, long id) {
        SuggestedLocaleAdapter adapter = (SuggestedLocaleAdapter) getListAdapter();
        final LocaleStore.LocaleInfo locale =
        final LocaleStore.LocaleInfo locale =
                (LocaleStore.LocaleInfo) adapter.getItem(position);
                (LocaleStore.LocaleInfo) parent.getAdapter().getItem(position);
        // Special case for resetting the app locale to equal the system locale.
        // Special case for resetting the app locale to equal the system locale.
        boolean isSystemLocale = locale.isSystemLocale();
        boolean isSystemLocale = locale.isSystemLocale();
        boolean isRegionLocale = locale.getParent() != null;
        boolean isRegionLocale = locale.getParent() != null;
@@ -280,7 +279,7 @@ public class LocalePickerWithRegion extends ListFragment implements SearchView.O
        } else {
        } else {
            LocalePickerWithRegion selector = LocalePickerWithRegion.createCountryPicker(
            LocalePickerWithRegion selector = LocalePickerWithRegion.createCountryPicker(
                    getContext(), mListener, locale, mTranslatedOnly /* translate only */,
                    getContext(), mListener, locale, mTranslatedOnly /* translate only */,
                    adapter.getAppPackageName());
                    mAppPackageName);
            if (selector != null) {
            if (selector != null) {
                getFragmentManager().beginTransaction()
                getFragmentManager().beginTransaction()
                        .setTransition(FragmentTransaction.TRANSIT_FRAGMENT_OPEN)
                        .setTransition(FragmentTransaction.TRANSIT_FRAGMENT_OPEN)
+0 −4
Original line number Original line Diff line number Diff line
@@ -348,8 +348,4 @@ public class SuggestedLocaleAdapter extends BaseAdapter implements Filterable {
    public Filter getFilter() {
    public Filter getFilter() {
        return new FilterByNativeAndUiNames();
        return new FilterByNativeAndUiNames();
    }
    }

    public String getAppPackageName() {
        return mAppPackageName;
    }
}
}