File tree Expand file tree Collapse file tree
Hyperrail/src/main/java/be/hyperrail/android/fragments
OpenTransport/src/main/java/be/hyperrail/opentransportdata/common/contracts
opentransport_be/src/main/java/be/hyperrail/opentransportdata/be/irail Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -445,7 +445,8 @@ private static class LoadAutoCompleteTask extends AsyncTask<TransportStopsDataSo
445445 @ Override
446446 protected String [] doInBackground (TransportStopsDataSource ... provider ) {
447447 Thread .currentThread ().setName ("LoadAutoCompleteTask" );
448- return provider [0 ].getStoplocationsNames (provider [0 ].getStoplocationsOrderedBySize ());
448+ // TODO: "make use of translations" a setting
449+ return provider [0 ].getStoplocationsNames (provider [0 ].getStoplocationsOrderedBySize (), false );
449450
450451 }
451452
Original file line number Diff line number Diff line change 1313package be .hyperrail .opentransportdata .common .contracts ;
1414
1515import android .location .Location ;
16+
1617import androidx .annotation .NonNull ;
1718import androidx .annotation .Nullable ;
1819
@@ -28,11 +29,13 @@ public interface TransportStopsDataSource {
2829 /**
2930 * Get all station names, localized.
3031 *
31- * @param stopLocations The list of stations for which a name should be retrieved.
32+ * @param stopLocations The list of stations for which a name should be retrieved.
33+ * @param includeTranslations Whether translations should be included in the name list.
34+ * If this is set to false, only localized names are used.
3235 * @return An array of localized station names.
3336 */
3437 @ NonNull
35- String [] getStoplocationsNames (@ NonNull StopLocation [] stopLocations );
38+ String [] getStoplocationsNames (@ NonNull StopLocation [] stopLocations , boolean includeTranslations );
3639
3740
3841 /**
Original file line number Diff line number Diff line change 1818
1919import java .util .Arrays ;
2020import java .util .HashMap ;
21+ import java .util .HashSet ;
2122import java .util .Locale ;
2223import java .util .Map ;
24+ import java .util .Set ;
2325
2426import be .hyperrail .opentransportdata .common .contracts .TransportStopsDataSource ;
2527import be .hyperrail .opentransportdata .common .exceptions .StopLocationNotResolvedException ;
@@ -167,17 +169,20 @@ public void preloadDatabase() {
167169 */
168170 @ NonNull
169171 @ Override
170- public String [] getStoplocationsNames (@ NonNull StopLocation [] stopLocations ) {
172+ public String [] getStoplocationsNames (@ NonNull StopLocation [] stopLocations , boolean includeTranslations ) {
171173 if (stopLocations .length == 0 ) {
172174 log .warning ("Tried to load station names on empty station list!" );
173175 return new String [0 ];
174176 }
175177
176- String [] results = new String [stopLocations .length ];
177- for (int i = 0 ; i < stopLocations .length ; i ++) {
178- results [i ] = stopLocations [i ].getLocalizedName ();
178+ Set <String > results = new HashSet <>();
179+ for (StopLocation stopLocation : stopLocations ) {
180+ results .add (stopLocation .getName ());
181+ if (includeTranslations ) {
182+ results .addAll (stopLocation .getTranslations ().values ());
183+ }
179184 }
180- return results ;
185+ return results . toArray ( new String [ 0 ]) ;
181186 }
182187
183188 @ Nullable
You can’t perform that action at this time.
0 commit comments