public class LocaleUtils extends Object
Constructor and Description |
---|
LocaleUtils() |
Modifier and Type | Method and Description |
---|---|
String |
getNonEmptyLanguage(Context context,
String language)
Returns the locale passed in if it is not null, otherwise returns the device locale
|
String |
getUnitTypeForDeviceLocale(Context context)
Returns the unit type for the device locale
|
String |
getUnitTypeForLocale(Locale locale)
Returns the unit type for the specified locale.
|
String |
inferDeviceLanguage(Context context)
Returns the device language to default to if no locale was specified
|
Locale |
inferDeviceLocale(Context context)
Returns the device locale for which to use as a default if no language is specified
|
String |
retrieveNonNullUnitType(Context context,
String unitType)
Returns the unitType passed in if it is not null, otherwise returns the a unitType
based on the device Locale.
|
public String getUnitTypeForLocale(@NonNull Locale locale)
locale
- for which to return the default unit typepublic String inferDeviceLanguage(Context context)
context
- to check configurationpublic Locale inferDeviceLocale(Context context)
context
- to check configurationpublic String getNonEmptyLanguage(Context context, String language)
context
- to get device localelanguage
- to check if it is nullpublic String getUnitTypeForDeviceLocale(Context context)
context
- from which to get the configurationpublic String retrieveNonNullUnitType(Context context, String unitType)
context
- to get device localeunitType
- to check if it is null© 2019 Mapbox. All rights reserved.