You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

113 lines
4.2 KiB

package androidx.savedstate;
import android.os.Bundle;
import androidx.lifecycle.AbstractC0424i;
import androidx.lifecycle.InterfaceC0432k;
import androidx.lifecycle.InterfaceC0434m;
import java.lang.reflect.Constructor;
import java.util.ArrayList;
import java.util.LinkedHashSet;
import java.util.Set;
import p039m1.C1468e;
import p039m1.C1470g;
import p065v0.C1755c;
import p065v0.InterfaceC1761e;
/* loaded from: classes.dex */
public final class Recreator implements InterfaceC0432k {
/* renamed from: b */
public static final C0460a f1676b = new C0460a(null);
/* renamed from: a */
public final InterfaceC1761e f1677a;
/* renamed from: androidx.savedstate.Recreator$a */
/* loaded from: classes.dex */
public static final class C0460a {
public C0460a() {
}
public /* synthetic */ C0460a(C1468e c1468e) {
this();
}
}
/* renamed from: androidx.savedstate.Recreator$b */
/* loaded from: classes.dex */
public static final class C0461b implements C1755c.InterfaceC1758c {
/* renamed from: a */
public final Set<String> f1678a;
public C0461b(C1755c c1755c) {
C1470g.m1292e(c1755c, "registry");
this.f1678a = new LinkedHashSet();
c1755c.m464h("androidx.savedstate.Restarter", this);
}
@Override // p065v0.C1755c.InterfaceC1758c
/* renamed from: a */
public Bundle mo461a() {
Bundle bundle = new Bundle();
bundle.putStringArrayList("classes_to_restore", new ArrayList<>(this.f1678a));
return bundle;
}
/* renamed from: b */
public final void m3638b(String str) {
C1470g.m1292e(str, "className");
this.f1678a.add(str);
}
}
public Recreator(InterfaceC1761e interfaceC1761e) {
C1470g.m1292e(interfaceC1761e, "owner");
this.f1677a = interfaceC1761e;
}
@Override // androidx.lifecycle.InterfaceC0432k
/* renamed from: d */
public void mo472d(InterfaceC0434m interfaceC0434m, AbstractC0424i.EnumC0426b enumC0426b) {
C1470g.m1292e(interfaceC0434m, "source");
C1470g.m1292e(enumC0426b, "event");
if (enumC0426b != AbstractC0424i.EnumC0426b.ON_CREATE) {
throw new AssertionError("Next event must be ON_CREATE");
}
interfaceC0434m.mo421a().mo3691c(this);
Bundle m470b = this.f1677a.mo454d().m470b("androidx.savedstate.Restarter");
if (m470b == null) {
return;
}
ArrayList<String> stringArrayList = m470b.getStringArrayList("classes_to_restore");
if (stringArrayList == null) {
throw new IllegalStateException("Bundle with restored state for the component \"androidx.savedstate.Restarter\" must contain list of strings by the key \"classes_to_restore\"");
}
for (String str : stringArrayList) {
m3639h(str);
}
}
/* renamed from: h */
public final void m3639h(String str) {
try {
Class<? extends U> asSubclass = Class.forName(str, false, Recreator.class.getClassLoader()).asSubclass(C1755c.InterfaceC1756a.class);
C1470g.m1293d(asSubclass, "{\n Class.\u2026class.java)\n }");
try {
Constructor declaredConstructor = asSubclass.getDeclaredConstructor(new Class[0]);
declaredConstructor.setAccessible(true);
try {
Object newInstance = declaredConstructor.newInstance(new Object[0]);
C1470g.m1293d(newInstance, "{\n constr\u2026wInstance()\n }");
((C1755c.InterfaceC1756a) newInstance).mo462a(this.f1677a);
} catch (Exception e) {
throw new RuntimeException("Failed to instantiate " + str, e);
}
} catch (NoSuchMethodException e2) {
throw new IllegalStateException("Class " + asSubclass.getSimpleName() + " must have default constructor in order to be automatically recreated", e2);
}
} catch (ClassNotFoundException e3) {
throw new RuntimeException("Class " + str + " wasn't found", e3);
}
}
}