|
1 | 1 | package be.hyperrail.android.adapter;
|
2 | 2 |
|
3 | 3 | import android.database.DataSetObserver;
|
| 4 | +import android.util.Log; |
4 | 5 | import android.view.LayoutInflater;
|
5 | 6 | import android.view.View;
|
6 | 7 | import android.view.ViewGroup;
|
@@ -52,7 +53,7 @@ public MultilangFilterResults(List<StopLocation> results) {
|
52 | 53 | @Override
|
53 | 54 | protected FilterResults performFiltering(CharSequence constraint) {
|
54 | 55 | List<StopLocation> list = new ArrayList<>();
|
55 |
| - if (constraint == null){ // no filtering |
| 56 | + if (constraint == null) { // no filtering |
56 | 57 | constraint = ""; // allows using the same sorter a little later
|
57 | 58 | list.addAll(Arrays.asList(stations));
|
58 | 59 | } else {
|
@@ -84,11 +85,19 @@ protected void publishResults(CharSequence constraint, FilterResults results) {
|
84 | 85 | //noinspection unchecked
|
85 | 86 | updateVisibleStops((List<StopLocation>) results.values);
|
86 | 87 | }
|
| 88 | + |
| 89 | + @Override |
| 90 | + public CharSequence convertResultToString(Object resultValue) { |
| 91 | + if (resultValue instanceof StopLocation) { |
| 92 | + return ((StopLocation) resultValue).getLocalizedName(); |
| 93 | + } |
| 94 | + return resultValue == null ? "" : resultValue.toString(); |
| 95 | + } |
87 | 96 | };
|
88 | 97 | }
|
89 | 98 |
|
90 | 99 | private void updateVisibleStops(List<StopLocation> stops) {
|
91 |
| - if (stops == null){ |
| 100 | + if (stops == null) { |
92 | 101 | FirebaseCrashlytics.getInstance().recordException(new IllegalArgumentException("Tried to set null in MultilangAutocompleteAdapter!"));
|
93 | 102 | stops = new ArrayList<>(); // Never allow setting null, even when there are issues with the autocomplete
|
94 | 103 | }
|
|
0 commit comments