Skip to content

Commit f08b671

Browse files
committed
Fix incorrect autocomplete value on click
1 parent 9e3cd5a commit f08b671

File tree

2 files changed

+13
-4
lines changed

2 files changed

+13
-4
lines changed

Hyperrail/build.gradle

+2-2
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@ apply plugin: 'com.android.application'
88
apply plugin: 'com.google.gms.google-services'
99
apply plugin: 'com.google.firebase.crashlytics'
1010

11-
def VERSION_CODE = 60
12-
def VERSION_NAME = '1.4.1'
11+
def VERSION_CODE = 61
12+
def VERSION_NAME = '1.4.2'
1313

1414
android {
1515
compileSdk 34

Hyperrail/src/main/java/be/hyperrail/android/adapter/MultilangAutocompleteAdapter.java

+11-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package be.hyperrail.android.adapter;
22

33
import android.database.DataSetObserver;
4+
import android.util.Log;
45
import android.view.LayoutInflater;
56
import android.view.View;
67
import android.view.ViewGroup;
@@ -52,7 +53,7 @@ public MultilangFilterResults(List<StopLocation> results) {
5253
@Override
5354
protected FilterResults performFiltering(CharSequence constraint) {
5455
List<StopLocation> list = new ArrayList<>();
55-
if (constraint == null){ // no filtering
56+
if (constraint == null) { // no filtering
5657
constraint = ""; // allows using the same sorter a little later
5758
list.addAll(Arrays.asList(stations));
5859
} else {
@@ -84,11 +85,19 @@ protected void publishResults(CharSequence constraint, FilterResults results) {
8485
//noinspection unchecked
8586
updateVisibleStops((List<StopLocation>) results.values);
8687
}
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+
}
8796
};
8897
}
8998

9099
private void updateVisibleStops(List<StopLocation> stops) {
91-
if (stops == null){
100+
if (stops == null) {
92101
FirebaseCrashlytics.getInstance().recordException(new IllegalArgumentException("Tried to set null in MultilangAutocompleteAdapter!"));
93102
stops = new ArrayList<>(); // Never allow setting null, even when there are issues with the autocomplete
94103
}

0 commit comments

Comments
 (0)