mirror of
https://github.com/Pinball3D/Rabbit-R1.git
synced 2024-12-30 11:02:31 -06:00
115 lines
4.4 KiB
Java
115 lines
4.4 KiB
Java
package androidx.media3.common.util;
|
|
|
|
import android.os.Bundle;
|
|
import android.util.SparseArray;
|
|
import androidx.media3.common.Bundleable;
|
|
import com.google.common.base.Function;
|
|
import com.google.common.collect.ImmutableList;
|
|
import com.google.common.collect.ImmutableMap;
|
|
import java.util.ArrayList;
|
|
import java.util.Collection;
|
|
import java.util.HashMap;
|
|
import java.util.Iterator;
|
|
import java.util.List;
|
|
import java.util.Map;
|
|
|
|
/* loaded from: classes2.dex */
|
|
public final class BundleableUtil {
|
|
public static <T extends Bundleable> ImmutableList<Bundle> toBundleList(List<T> list) {
|
|
return toBundleList(list, new Function() { // from class: androidx.media3.common.util.BundleableUtil$$ExternalSyntheticLambda0
|
|
@Override // com.google.common.base.Function
|
|
public final Object apply(Object obj) {
|
|
return ((Bundleable) obj).toBundle();
|
|
}
|
|
});
|
|
}
|
|
|
|
public static <T extends Bundleable> ImmutableList<Bundle> toBundleList(List<T> list, Function<T, Bundle> function) {
|
|
ImmutableList.Builder builder = ImmutableList.builder();
|
|
for (int i = 0; i < list.size(); i++) {
|
|
builder.add((ImmutableList.Builder) function.apply(list.get(i)));
|
|
}
|
|
return builder.build();
|
|
}
|
|
|
|
public static <T extends Bundleable> ImmutableList<T> fromBundleList(Bundleable.Creator<T> creator, List<Bundle> list) {
|
|
ImmutableList.Builder builder = ImmutableList.builder();
|
|
for (int i = 0; i < list.size(); i++) {
|
|
builder.add((ImmutableList.Builder) creator.fromBundle((Bundle) Assertions.checkNotNull(list.get(i))));
|
|
}
|
|
return builder.build();
|
|
}
|
|
|
|
public static <T extends Bundleable> ArrayList<Bundle> toBundleArrayList(Collection<T> collection) {
|
|
ArrayList<Bundle> arrayList = new ArrayList<>(collection.size());
|
|
Iterator<T> it = collection.iterator();
|
|
while (it.hasNext()) {
|
|
arrayList.add(it.next().toBundle());
|
|
}
|
|
return arrayList;
|
|
}
|
|
|
|
public static <T extends Bundleable> SparseArray<T> fromBundleSparseArray(Bundleable.Creator<T> creator, SparseArray<Bundle> sparseArray) {
|
|
SparseArray<T> sparseArray2 = new SparseArray<>(sparseArray.size());
|
|
for (int i = 0; i < sparseArray.size(); i++) {
|
|
sparseArray2.put(sparseArray.keyAt(i), creator.fromBundle(sparseArray.valueAt(i)));
|
|
}
|
|
return sparseArray2;
|
|
}
|
|
|
|
public static <T extends Bundleable> SparseArray<Bundle> toBundleSparseArray(SparseArray<T> sparseArray) {
|
|
SparseArray<Bundle> sparseArray2 = new SparseArray<>(sparseArray.size());
|
|
for (int i = 0; i < sparseArray.size(); i++) {
|
|
sparseArray2.put(sparseArray.keyAt(i), sparseArray.valueAt(i).toBundle());
|
|
}
|
|
return sparseArray2;
|
|
}
|
|
|
|
public static Bundle stringMapToBundle(Map<String, String> map) {
|
|
Bundle bundle = new Bundle();
|
|
for (Map.Entry<String, String> entry : map.entrySet()) {
|
|
bundle.putString(entry.getKey(), entry.getValue());
|
|
}
|
|
return bundle;
|
|
}
|
|
|
|
public static HashMap<String, String> bundleToStringHashMap(Bundle bundle) {
|
|
HashMap<String, String> hashMap = new HashMap<>();
|
|
if (bundle == Bundle.EMPTY) {
|
|
return hashMap;
|
|
}
|
|
for (String str : bundle.keySet()) {
|
|
String string = bundle.getString(str);
|
|
if (string != null) {
|
|
hashMap.put(str, string);
|
|
}
|
|
}
|
|
return hashMap;
|
|
}
|
|
|
|
public static ImmutableMap<String, String> bundleToStringImmutableMap(Bundle bundle) {
|
|
if (bundle == Bundle.EMPTY) {
|
|
return ImmutableMap.of();
|
|
}
|
|
return ImmutableMap.copyOf((Map) bundleToStringHashMap(bundle));
|
|
}
|
|
|
|
public static Bundle getBundleWithDefault(Bundle bundle, String str, Bundle bundle2) {
|
|
Bundle bundle3 = bundle.getBundle(str);
|
|
return bundle3 != null ? bundle3 : bundle2;
|
|
}
|
|
|
|
public static ArrayList<Integer> getIntegerArrayListWithDefault(Bundle bundle, String str, ArrayList<Integer> arrayList) {
|
|
ArrayList<Integer> integerArrayList = bundle.getIntegerArrayList(str);
|
|
return integerArrayList != null ? integerArrayList : arrayList;
|
|
}
|
|
|
|
public static void ensureClassLoader(Bundle bundle) {
|
|
if (bundle != null) {
|
|
bundle.setClassLoader((ClassLoader) Util.castNonNull(BundleableUtil.class.getClassLoader()));
|
|
}
|
|
}
|
|
|
|
private BundleableUtil() {
|
|
}
|
|
}
|