@Test public void testForLanguageTags() { assertEquals(LocaleListCompat.getEmptyLocaleList(), LocaleListCompat.forLanguageTags(null)); assertEquals(LocaleListCompat.getEmptyLocaleList(), LocaleListCompat.forLanguageTags("")); assertEquals(LocaleListCompat.create(forLanguageTag("en-US")), LocaleListCompat.forLanguageTags("en-US")); final Locale[] la = {forLanguageTag("en-PH"), forLanguageTag("en-US")}; assertEquals(LocaleListCompat.create(la), LocaleListCompat.forLanguageTags("en-PH,en-US")); }
@NonNull public static LocaleListCompat forLanguageTags(@Nullable String list) { if (list == null || list.isEmpty()) { return getEmptyLocaleList(); } else { final String[] tags = list.split(",", -1); final Locale[] localeArray = new Locale[tags.length]; for (int i = 0; i < localeArray.length; i++) { localeArray[i] = Build.VERSION.SDK_INT >= 21 ? Locale.forLanguageTag(tags[i]) : LocaleHelper.forLanguageTag(tags[i]); } LocaleListCompat instance = new LocaleListCompat(); instance.setLocaleListArray(localeArray); return instance; } }
LocaleListCompat { @NonNull public static LocaleListCompat forLanguageTags(@Nullable String list) { if (list == null || list.isEmpty()) { return getEmptyLocaleList(); } else { final String[] tags = list.split(",", -1); final Locale[] localeArray = new Locale[tags.length]; for (int i = 0; i < localeArray.length; i++) { localeArray[i] = Build.VERSION.SDK_INT >= 21 ? Locale.forLanguageTag(tags[i]) : LocaleHelper.forLanguageTag(tags[i]); } LocaleListCompat instance = new LocaleListCompat(); instance.setLocaleListArray(localeArray); return instance; } } }
LocaleListCompat { @NonNull public static LocaleListCompat forLanguageTags(@Nullable String list) { if (list == null || list.isEmpty()) { return getEmptyLocaleList(); } else { final String[] tags = list.split(",", -1); final Locale[] localeArray = new Locale[tags.length]; for (int i = 0; i < localeArray.length; i++) { localeArray[i] = Build.VERSION.SDK_INT >= 21 ? Locale.forLanguageTag(tags[i]) : LocaleHelper.forLanguageTag(tags[i]); } LocaleListCompat instance = new LocaleListCompat(); instance.setLocaleListArray(localeArray); return instance; } } private  LocaleListCompat(); }
LocaleListCompat { @NonNull public static LocaleListCompat forLanguageTags(@Nullable String list) { if (list == null || list.isEmpty()) { return getEmptyLocaleList(); } else { final String[] tags = list.split(",", -1); final Locale[] localeArray = new Locale[tags.length]; for (int i = 0; i < localeArray.length; i++) { localeArray[i] = Build.VERSION.SDK_INT >= 21 ? Locale.forLanguageTag(tags[i]) : LocaleHelper.forLanguageTag(tags[i]); } LocaleListCompat instance = new LocaleListCompat(); instance.setLocaleListArray(localeArray); return instance; } } private  LocaleListCompat(); @RequiresApi(24) static LocaleListCompat wrap(Object object); @Nullable Object unwrap(); static LocaleListCompat create(@NonNull Locale... localeList); Locale get(int index); boolean isEmpty(); @IntRange(from = 0) int size(); @IntRange(from = -1) int indexOf(Locale locale); @NonNull String toLanguageTags(); Locale getFirstMatch(String[] supportedLocales); @NonNull static LocaleListCompat getEmptyLocaleList(); @NonNull static LocaleListCompat forLanguageTags(@Nullable String list); @NonNull @Size(min = 1) static LocaleListCompat getAdjustedDefault(); @NonNull @Size(min = 1) static LocaleListCompat getDefault(); @Override boolean equals(Object other); @Override int hashCode(); @Override String toString(); }
LocaleListCompat { @NonNull public static LocaleListCompat forLanguageTags(@Nullable String list) { if (list == null || list.isEmpty()) { return getEmptyLocaleList(); } else { final String[] tags = list.split(",", -1); final Locale[] localeArray = new Locale[tags.length]; for (int i = 0; i < localeArray.length; i++) { localeArray[i] = Build.VERSION.SDK_INT >= 21 ? Locale.forLanguageTag(tags[i]) : LocaleHelper.forLanguageTag(tags[i]); } LocaleListCompat instance = new LocaleListCompat(); instance.setLocaleListArray(localeArray); return instance; } } private  LocaleListCompat(); @RequiresApi(24) static LocaleListCompat wrap(Object object); @Nullable Object unwrap(); static LocaleListCompat create(@NonNull Locale... localeList); Locale get(int index); boolean isEmpty(); @IntRange(from = 0) int size(); @IntRange(from = -1) int indexOf(Locale locale); @NonNull String toLanguageTags(); Locale getFirstMatch(String[] supportedLocales); @NonNull static LocaleListCompat getEmptyLocaleList(); @NonNull static LocaleListCompat forLanguageTags(@Nullable String list); @NonNull @Size(min = 1) static LocaleListCompat getAdjustedDefault(); @NonNull @Size(min = 1) static LocaleListCompat getDefault(); @Override boolean equals(Object other); @Override int hashCode(); @Override String toString();  }