Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Request] Add an option for setting the Locale parameter from outside #257

Open
burekas7 opened this issue Nov 9, 2018 · 0 comments
Open

Comments

@burekas7
Copy link

burekas7 commented Nov 9, 2018

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.

@burekas7 burekas7 changed the title [Request] Option for set the Locale parameter [Request] Add an option for setting the Locale parameter from outside Nov 9, 2018
burekas7 added a commit to burekas7/smart-location-lib that referenced this issue Nov 26, 2018
Add an option for setting the Locale parameter from outside

mrmans0n#257
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant