本文整理汇总了Java中android.os.LocaleList.size方法的典型用法代码示例。如果您正苦于以下问题:Java LocaleList.size方法的具体用法?Java LocaleList.size怎么用?Java LocaleList.size使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类android.os.LocaleList
的用法示例。
在下文中一共展示了LocaleList.size方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getDefault
import android.os.LocaleList; //导入方法依赖的package包/类
public static List<Locale> getDefault(Context context, boolean getAllIfPossible) {
List<Locale> list = new ArrayList();
if (VERSION.SDK_INT >= 24) {
LocaleList locales = context.getResources().getConfiguration().getLocales();
for (int i = 0; i < locales.size(); i++) {
Locale locale = locales.get(i);
if (!getAllIfPossible) {
list.add(locale);
break;
}
list.add(locale);
}
} else {
list.add(context.getResources().getConfiguration().locale);
}
return list;
}
示例2: AlphabeticIndexVN
import android.os.LocaleList; //导入方法依赖的package包/类
AlphabeticIndexVN(Context context) {
LocaleList locales = context.getResources().getConfiguration().getLocales();
int localeCount = locales.size();
Locale primaryLocale = localeCount == 0 ? Locale.ENGLISH : locales.get(0);
AlphabeticIndex indexBuilder = new AlphabeticIndex(primaryLocale);
for (int i = 1; i < localeCount; i++) {
indexBuilder.addLabels(locales.get(i));
}
indexBuilder.addLabels(Locale.ENGLISH);
mAlphabeticIndex = indexBuilder.buildImmutableIndex();
}
示例3: mapToListOfLocales
import android.os.LocaleList; //导入方法依赖的package包/类
@RequiresApi(api = Build.VERSION_CODES.N)
private static List<Locale> mapToListOfLocales(LocaleList localeList) {
List<Locale> locales = new ArrayList<>();
for (int i = 0; i < localeList.size(); i++) {
locales.add(localeList.get(i));
}
return locales;
}
示例4: AlphabeticIndexVN
import android.os.LocaleList; //导入方法依赖的package包/类
public AlphabeticIndexVN(Context context) {
LocaleList locales = context.getResources().getConfiguration().getLocales();
int localeCount = locales.size();
Locale primaryLocale = localeCount == 0 ? Locale.ENGLISH : locales.get(0);
AlphabeticIndex indexBuilder = new AlphabeticIndex(primaryLocale);
for (int i = 1; i < localeCount; i++) {
indexBuilder.addLabels(locales.get(i));
}
indexBuilder.addLabels(Locale.ENGLISH);
mAlphabeticIndex = indexBuilder.buildImmutableIndex();
}
示例5: toLanguageTags
import android.os.LocaleList; //导入方法依赖的package包/类
/**
* Converts LocaleList object to the comma separated BCP 47 compliant string format.
*
* @return a well-formed IETF BCP 47 language tag with language and country code that
* represents this locale list.
*/
@TargetApi(Build.VERSION_CODES.N)
public static String toLanguageTags(LocaleList localeList) {
ArrayList<String> newLocaleList = new ArrayList<>();
for (int i = 0; i < localeList.size(); i++) {
Locale locale = getUpdatedLocaleForChromium(localeList.get(i));
newLocaleList.add(toLanguageTag(locale));
}
return TextUtils.join(",", newLocaleList);
}
示例6: getLocale
import android.os.LocaleList; //导入方法依赖的package包/类
private Locale getLocale() {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {
LocaleList locales = getConfiguration().getLocales();
if (locales.size() > 0) {
return locales.get(0);
}
}
return getConfiguration().locale;
}
示例7: list
import android.os.LocaleList; //导入方法依赖的package包/类
@SuppressWarnings("deprecation")
@TargetApi(Build.VERSION_CODES.N)
private ArrayList<Locale> list(Configuration configuration) {
ArrayList<Locale> arrayList = new ArrayList<>();
if (C.API_NOUGAT) {
LocaleList localeList = configuration.getLocales();
for (int i = 0; i < localeList.size(); i++) {
arrayList.add(localeList.get(i));
}
} else {
arrayList.add(configuration.locale);
}
return arrayList;
}