- 28,932 files - Full Java source code - Smali files - Resources Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
110 lines
3.9 KiB
Java
110 lines
3.9 KiB
Java
package androidx.core.os;
|
|
|
|
import android.annotation.SuppressLint;
|
|
import android.os.Build;
|
|
import android.os.Bundle;
|
|
import android.os.IBinder;
|
|
import android.os.Parcelable;
|
|
import android.util.SparseArray;
|
|
import androidx.annotation.NonNull;
|
|
import androidx.annotation.Nullable;
|
|
import androidx.annotation.ReplaceWith;
|
|
import androidx.annotation.RequiresApi;
|
|
import java.io.Serializable;
|
|
import java.util.ArrayList;
|
|
|
|
/* loaded from: classes.dex */
|
|
public final class BundleCompat {
|
|
private BundleCompat() {
|
|
}
|
|
|
|
@Nullable
|
|
public static <T> T getParcelable(@NonNull Bundle bundle, @Nullable String str, @NonNull Class<T> cls) {
|
|
if (Build.VERSION.SDK_INT >= 34) {
|
|
return (T) Api33Impl.getParcelable(bundle, str, cls);
|
|
}
|
|
T t = (T) bundle.getParcelable(str);
|
|
if (cls.isInstance(t)) {
|
|
return t;
|
|
}
|
|
return null;
|
|
}
|
|
|
|
@Nullable
|
|
@SuppressLint({"ArrayReturn", "NullableCollection"})
|
|
public static Parcelable[] getParcelableArray(@NonNull Bundle bundle, @Nullable String str, @NonNull Class<? extends Parcelable> cls) {
|
|
if (Build.VERSION.SDK_INT >= 34) {
|
|
return (Parcelable[]) Api33Impl.getParcelableArray(bundle, str, cls);
|
|
}
|
|
return bundle.getParcelableArray(str);
|
|
}
|
|
|
|
@Nullable
|
|
@SuppressLint({"ConcreteCollection", "NullableCollection"})
|
|
public static <T> ArrayList<T> getParcelableArrayList(@NonNull Bundle bundle, @Nullable String str, @NonNull Class<? extends T> cls) {
|
|
if (Build.VERSION.SDK_INT >= 34) {
|
|
return Api33Impl.getParcelableArrayList(bundle, str, cls);
|
|
}
|
|
return bundle.getParcelableArrayList(str);
|
|
}
|
|
|
|
@Nullable
|
|
public static <T> SparseArray<T> getSparseParcelableArray(@NonNull Bundle bundle, @Nullable String str, @NonNull Class<? extends T> cls) {
|
|
if (Build.VERSION.SDK_INT >= 34) {
|
|
return Api33Impl.getSparseParcelableArray(bundle, str, cls);
|
|
}
|
|
return bundle.getSparseParcelableArray(str);
|
|
}
|
|
|
|
@Nullable
|
|
@ReplaceWith(expression = "bundle.getBinder(key)")
|
|
@Deprecated
|
|
public static IBinder getBinder(@NonNull Bundle bundle, @Nullable String str) {
|
|
return bundle.getBinder(str);
|
|
}
|
|
|
|
@ReplaceWith(expression = "bundle.putBinder(key, binder)")
|
|
@Deprecated
|
|
public static void putBinder(@NonNull Bundle bundle, @Nullable String str, @Nullable IBinder iBinder) {
|
|
bundle.putBinder(str, iBinder);
|
|
}
|
|
|
|
@Nullable
|
|
public static <T extends Serializable> T getSerializable(@NonNull Bundle bundle, @Nullable String str, @NonNull Class<T> cls) {
|
|
if (Build.VERSION.SDK_INT >= 34) {
|
|
return (T) Api33Impl.getSerializable(bundle, str, cls);
|
|
}
|
|
T t = (T) bundle.getSerializable(str);
|
|
if (cls.isInstance(t)) {
|
|
return t;
|
|
}
|
|
return null;
|
|
}
|
|
|
|
@RequiresApi(33)
|
|
public static class Api33Impl {
|
|
private Api33Impl() {
|
|
}
|
|
|
|
public static <T> T getParcelable(@NonNull Bundle bundle, @Nullable String str, @NonNull Class<T> cls) {
|
|
return (T) bundle.getParcelable(str, cls);
|
|
}
|
|
|
|
public static <T> T[] getParcelableArray(@NonNull Bundle bundle, @Nullable String str, @NonNull Class<T> cls) {
|
|
return (T[]) bundle.getParcelableArray(str, cls);
|
|
}
|
|
|
|
public static <T> ArrayList<T> getParcelableArrayList(@NonNull Bundle bundle, @Nullable String str, @NonNull Class<? extends T> cls) {
|
|
return bundle.getParcelableArrayList(str, cls);
|
|
}
|
|
|
|
public static <T> SparseArray<T> getSparseParcelableArray(@NonNull Bundle bundle, @Nullable String str, @NonNull Class<? extends T> cls) {
|
|
return bundle.getSparseParcelableArray(str, cls);
|
|
}
|
|
|
|
public static <T extends Serializable> T getSerializable(@NonNull Bundle bundle, @Nullable String str, @NonNull Class<T> cls) {
|
|
return (T) bundle.getSerializable(str, cls);
|
|
}
|
|
}
|
|
}
|