alexandroid/decompiled/jadx/sources/androidx/versionedparcelable/ParcelUtils.java
KaKi87 a47fad5135 📦 Add decompiled Alexa 2.2.730155.0 (jadx, apktool, Hermes strings)
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-11-07 00:04:16 +01:00

98 lines
3.8 KiB
Java

package androidx.versionedparcelable;
import android.os.Bundle;
import android.os.Parcelable;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.annotation.RestrictTo;
import java.io.InputStream;
import java.io.OutputStream;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import rx.Single$$ExternalSyntheticBUOutline0;
/* compiled from: r8-map-id-b9432e0f623b4a4bff4ba50a8a24c4aafad2c1e11092747b9fb5e6a22af5a940 */
/* loaded from: classes14.dex */
public class ParcelUtils {
private static final String INNER_BUNDLE_KEY = "a";
private ParcelUtils() {
}
@RestrictTo({RestrictTo.Scope.LIBRARY_GROUP_PREFIX})
public static <T extends VersionedParcelable> T fromInputStream(InputStream inputStream) {
return (T) new VersionedParcelStream(inputStream, null).readVersionedParcelable();
}
@RestrictTo({RestrictTo.Scope.LIBRARY_GROUP_PREFIX})
public static <T extends VersionedParcelable> T fromParcelable(Parcelable parcelable) {
if (parcelable instanceof ParcelImpl) {
return (T) ((ParcelImpl) parcelable).getVersionedParcel();
}
Single$$ExternalSyntheticBUOutline0.m$3("Invalid parcel");
return null;
}
@Nullable
public static <T extends VersionedParcelable> T getVersionedParcelable(@NonNull Bundle bundle, @NonNull String str) {
try {
Bundle bundle2 = (Bundle) bundle.getParcelable(str);
if (bundle2 == null) {
return null;
}
bundle2.setClassLoader(ParcelUtils.class.getClassLoader());
return (T) fromParcelable(bundle2.getParcelable("a"));
} catch (RuntimeException unused) {
return null;
}
}
@Nullable
public static <T extends VersionedParcelable> List<T> getVersionedParcelableList(Bundle bundle, String str) {
ArrayList arrayList = new ArrayList();
try {
Bundle bundle2 = (Bundle) bundle.getParcelable(str);
bundle2.setClassLoader(ParcelUtils.class.getClassLoader());
Iterator it2 = bundle2.getParcelableArrayList("a").iterator();
while (it2.hasNext()) {
arrayList.add(fromParcelable((Parcelable) it2.next()));
}
return arrayList;
} catch (RuntimeException unused) {
return null;
}
}
public static void putVersionedParcelable(@NonNull Bundle bundle, @NonNull String str, @Nullable VersionedParcelable versionedParcelable) {
if (versionedParcelable == null) {
return;
}
Bundle bundle2 = new Bundle();
bundle2.putParcelable("a", toParcelable(versionedParcelable));
bundle.putParcelable(str, bundle2);
}
public static void putVersionedParcelableList(@NonNull Bundle bundle, @NonNull String str, @NonNull List<? extends VersionedParcelable> list) {
Bundle bundle2 = new Bundle();
ArrayList<? extends Parcelable> arrayList = new ArrayList<>();
Iterator<? extends VersionedParcelable> it2 = list.iterator();
while (it2.hasNext()) {
arrayList.add(toParcelable(it2.next()));
}
bundle2.putParcelableArrayList("a", arrayList);
bundle.putParcelable(str, bundle2);
}
@RestrictTo({RestrictTo.Scope.LIBRARY_GROUP_PREFIX})
public static void toOutputStream(VersionedParcelable versionedParcelable, OutputStream outputStream) {
VersionedParcelStream versionedParcelStream = new VersionedParcelStream(null, outputStream);
versionedParcelStream.writeVersionedParcelable(versionedParcelable);
versionedParcelStream.closeField();
}
@RestrictTo({RestrictTo.Scope.LIBRARY_GROUP_PREFIX})
public static Parcelable toParcelable(VersionedParcelable versionedParcelable) {
return new ParcelImpl(versionedParcelable);
}
}