LocaleListCompat
class LocaleListCompat
Helper for accessing features in LocaleList.
Summary
Public functions |
|
|---|---|
java-static LocaleListCompat |
Creates a new instance of |
Boolean |
|
java-static LocaleListCompat |
forLanguageTags(list: String?)Generates a new LocaleList with the given language tags. |
Locale? |
Retrieves the |
java-static @Size(min = 1) LocaleListCompat |
Returns the default locale list, adjusted by moving the default locale to its first position. |
java-static @Size(min = 1) LocaleListCompat |
The result is guaranteed to include the default Locale returned by Locale.getDefault(), but not necessarily at the top of the list. |
java-static LocaleListCompat |
Retrieve an empty instance of |
Locale? |
getFirstMatch(supportedLocales: Array<String!>)Returns the first match in the locale list given an unordered array of supported locales in BCP 47 format. |
Int |
hashCode() |
@IntRange(from = "-1") Int |
Searches this |
Boolean |
isEmpty()Returns whether the |
java-static Boolean |
@RequiresApi(value = 21)Determine whether two locales are considered a match, even if they are not exactly equal. |
@IntRange(from = 0) Int |
size()Returns the number of |
String |
Retrieves a String representation of the language tags in this list. |
String |
toString() |
Any? |
unwrap()Gets the underlying framework object. |
java-static LocaleListCompat! |
@RequiresApi(value = 24)This function is deprecated. Use |
java-static LocaleListCompat |
@RequiresApi(value = 24)Creates a new instance of |
Public functions
create
java-static fun create(localeList: Array<Locale!>): LocaleListCompat
Creates a new instance of LocaleListCompat from the Locale array.
forLanguageTags
java-static fun forLanguageTags(list: String?): LocaleListCompat
Generates a new LocaleList with the given language tags.
Note that for API <24 only the first language tag will be used.
| Returns | |
|---|---|
LocaleListCompat |
A new instance with the |
get
fun get(index: Int): Locale?
Retrieves the Locale at the specified index.
| Parameters | |
|---|---|
index: Int |
The position to retrieve. |
getAdjustedDefault
java-static fun getAdjustedDefault(): @Size(min = 1) LocaleListCompat
Returns the default locale list, adjusted by moving the default locale to its first position.
getDefault
java-static fun getDefault(): @Size(min = 1) LocaleListCompat
The result is guaranteed to include the default Locale returned by Locale.getDefault(), but not necessarily at the top of the list. The default locale not being at the top of the list is an indication that the system has set the default locale to one of the user's other preferred locales, having concluded that the primary preference is not supported but a secondary preference is.
Note that for API >= 24 the default LocaleList would change if Locale.setDefault() is called. This method takes that into account by always checking the output of Locale.getDefault() and recalculating the default LocaleList if needed.
getEmptyLocaleList
java-static fun getEmptyLocaleList(): LocaleListCompat
Retrieve an empty instance of LocaleListCompat.
getFirstMatch
fun getFirstMatch(supportedLocales: Array<String!>): Locale?
Returns the first match in the locale list given an unordered array of supported locales in BCP 47 format.
| Returns | |
|---|---|
Locale? |
The first |
indexOf
fun indexOf(locale: Locale?): @IntRange(from = "-1") Int
Searches this LocaleListCompat for the specified Locale and returns the index of the first occurrence.
isEmpty
fun isEmpty(): Boolean
Returns whether the LocaleListCompat contains no Locale items.
| Returns | |
|---|---|
Boolean |
|
matchesLanguageAndScript
@RequiresApi(value = 21)
java-static fun matchesLanguageAndScript(supported: Locale, desired: Locale): Boolean
Determine whether two locales are considered a match, even if they are not exactly equal. They are considered as a match when both of their languages and scripts (explicit or inferred) are identical. This means that a user would be able to understand the content written in the supported locale even if they say they prefer the desired locale. E.g. [zh-HK] matches [zh-Hant]; [en-US] matches [en-CA].
| Parameters | |
|---|---|
supported: Locale |
The supported |
desired: Locale |
The desired |
| Returns | |
|---|---|
Boolean |
True if they match, false otherwise. |
size
fun size(): @IntRange(from = 0) Int
Returns the number of Locale items in this LocaleListCompat.
toLanguageTags
fun toLanguageTags(): String
Retrieves a String representation of the language tags in this list.
unwrap
fun unwrap(): Any?
Gets the underlying framework object.
| Returns | |
|---|---|
Any? |
an android.os.LocaleList object if API >= 24 , or |
wrap
@RequiresApi(value = 24)
java-static fun wrap(localeList: LocaleList): LocaleListCompat
Creates a new instance of LocaleListCompat from the Locale list.