[Request] Add an option for setting the Locale parameter from outside
Opened this issue · 0 comments
burekas7 commented
Hi @mrmans0n , thanks for this library.
How can I change the Locale parameter from outside?
public Geocoder (Context context, Locale locale)
Currently in your code it can't be changed from outside, it always set to be as default by the device language.
Constructor always empty, or take a provider, but there is no way to use the other constructor with the Locale parameter.
geocoding()
/smartlocation/SmartLocation.java
/**
* @return request handler for geocoding operations
*/
public GeocodingControl geocoding() {
return geocoding(new AndroidGeocodingProvider());
}
/**
* @param geocodingProvider geocoding provider we want to use
* @return request handler for geocoding operations
*/
public GeocodingControl geocoding(GeocodingProvider geocodingProvider) {
return new GeocodingControl(this, geocodingProvider);
}
The AndroidGeocodingProvider Constructors:
/smartlocation/geocoding/providers/AndroidGeocodingProvider.java
public AndroidGeocodingProvider() {
this(Locale.getDefault());
}
public AndroidGeocodingProvider(Locale locale) {
if (locale == null) {
// This should be super weird
throw new RuntimeException("Locale is null");
}
this.locale = locale;
fromNameList = new HashMap<>();
fromLocationList = new HashMap<>();
if (!Geocoder.isPresent()) {
throw new RuntimeException("Android Geocoder not present. Please check if Geocoder.isPresent() before invoking the search");
}
}
So I need to be able working also with this constructor:
public AndroidGeocodingProvider(Locale locale) { … }
Currently It's not in use in your code, and cannot be used from outside with the geocoding() function.