Rabbit-R1/original r1/java/sources/androidx/appcompat/app/LocaleOverlayHelper.java

44 lines
1.7 KiB
Java
Raw Normal View History

2024-05-21 16:08:36 -05:00
package androidx.appcompat.app;
import android.os.LocaleList;
import androidx.core.os.LocaleListCompat;
import java.util.LinkedHashSet;
import java.util.Locale;
/* loaded from: classes.dex */
final class LocaleOverlayHelper {
private LocaleOverlayHelper() {
}
/* JADX INFO: Access modifiers changed from: package-private */
public static LocaleListCompat combineLocalesIfOverlayExists(LocaleListCompat localeListCompat, LocaleListCompat localeListCompat2) {
if (localeListCompat == null || localeListCompat.isEmpty()) {
return LocaleListCompat.getEmptyLocaleList();
}
return combineLocales(localeListCompat, localeListCompat2);
}
static LocaleListCompat combineLocalesIfOverlayExists(LocaleList localeList, LocaleList localeList2) {
if (localeList == null || localeList.isEmpty()) {
return LocaleListCompat.getEmptyLocaleList();
}
return combineLocales(LocaleListCompat.wrap(localeList), LocaleListCompat.wrap(localeList2));
}
private static LocaleListCompat combineLocales(LocaleListCompat localeListCompat, LocaleListCompat localeListCompat2) {
Locale locale;
LinkedHashSet linkedHashSet = new LinkedHashSet();
for (int i = 0; i < localeListCompat.size() + localeListCompat2.size(); i++) {
if (i < localeListCompat.size()) {
locale = localeListCompat.get(i);
} else {
locale = localeListCompat2.get(i - localeListCompat.size());
}
if (locale != null) {
linkedHashSet.add(locale);
}
}
return LocaleListCompat.create((Locale[]) linkedHashSet.toArray(new Locale[linkedHashSet.size()]));
}
}