ADD week 5
This commit is contained in:
15
02-Easy5/E5/sources/androidx/savedstate/R.java
Normal file
15
02-Easy5/E5/sources/androidx/savedstate/R.java
Normal file
@ -0,0 +1,15 @@
|
||||
package androidx.savedstate;
|
||||
|
||||
/* loaded from: classes.dex */
|
||||
public final class R {
|
||||
|
||||
public static final class id {
|
||||
public static final int view_tree_saved_state_registry_owner = 0x7f0801e5;
|
||||
|
||||
private id() {
|
||||
}
|
||||
}
|
||||
|
||||
private R() {
|
||||
}
|
||||
}
|
97
02-Easy5/E5/sources/androidx/savedstate/Recreator.java
Normal file
97
02-Easy5/E5/sources/androidx/savedstate/Recreator.java
Normal file
@ -0,0 +1,97 @@
|
||||
package androidx.savedstate;
|
||||
|
||||
import android.os.Bundle;
|
||||
import androidx.core.app.NotificationCompat;
|
||||
import androidx.lifecycle.Lifecycle;
|
||||
import androidx.lifecycle.LifecycleEventObserver;
|
||||
import androidx.lifecycle.LifecycleOwner;
|
||||
import androidx.savedstate.SavedStateRegistry;
|
||||
import java.lang.reflect.Constructor;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Iterator;
|
||||
import java.util.LinkedHashSet;
|
||||
import java.util.Set;
|
||||
import kotlin.Metadata;
|
||||
import kotlin.jvm.internal.Intrinsics;
|
||||
|
||||
/* compiled from: Recreator.kt */
|
||||
@Metadata(d1 = {"\u0000.\n\u0002\u0018\u0002\n\u0002\u0018\u0002\n\u0000\n\u0002\u0018\u0002\n\u0002\b\u0002\n\u0002\u0010\u0002\n\u0000\n\u0002\u0018\u0002\n\u0000\n\u0002\u0018\u0002\n\u0002\b\u0002\n\u0002\u0010\u000e\n\u0002\b\u0003\b\u0000\u0018\u0000 \u000e2\u00020\u0001:\u0002\u000e\u000fB\r\u0012\u0006\u0010\u0002\u001a\u00020\u0003¢\u0006\u0002\u0010\u0004J\u0018\u0010\u0005\u001a\u00020\u00062\u0006\u0010\u0007\u001a\u00020\b2\u0006\u0010\t\u001a\u00020\nH\u0016J\u0010\u0010\u000b\u001a\u00020\u00062\u0006\u0010\f\u001a\u00020\rH\u0002R\u000e\u0010\u0002\u001a\u00020\u0003X\u0082\u0004¢\u0006\u0002\n\u0000¨\u0006\u0010"}, d2 = {"Landroidx/savedstate/Recreator;", "Landroidx/lifecycle/LifecycleEventObserver;", "owner", "Landroidx/savedstate/SavedStateRegistryOwner;", "(Landroidx/savedstate/SavedStateRegistryOwner;)V", "onStateChanged", "", "source", "Landroidx/lifecycle/LifecycleOwner;", NotificationCompat.CATEGORY_EVENT, "Landroidx/lifecycle/Lifecycle$Event;", "reflectiveNew", "className", "", "Companion", "SavedStateProvider", "savedstate_release"}, k = 1, mv = {1, 8, 0}, xi = 48)
|
||||
/* loaded from: classes.dex */
|
||||
public final class Recreator implements LifecycleEventObserver {
|
||||
public static final String CLASSES_KEY = "classes_to_restore";
|
||||
public static final String COMPONENT_KEY = "androidx.savedstate.Restarter";
|
||||
private final SavedStateRegistryOwner owner;
|
||||
|
||||
public Recreator(SavedStateRegistryOwner owner) {
|
||||
Intrinsics.checkNotNullParameter(owner, "owner");
|
||||
this.owner = owner;
|
||||
}
|
||||
|
||||
@Override // androidx.lifecycle.LifecycleEventObserver
|
||||
public void onStateChanged(LifecycleOwner source, Lifecycle.Event event) {
|
||||
Intrinsics.checkNotNullParameter(source, "source");
|
||||
Intrinsics.checkNotNullParameter(event, "event");
|
||||
if (event != Lifecycle.Event.ON_CREATE) {
|
||||
throw new AssertionError("Next event must be ON_CREATE");
|
||||
}
|
||||
source.getLifecycle().removeObserver(this);
|
||||
Bundle consumeRestoredStateForKey = this.owner.getSavedStateRegistry().consumeRestoredStateForKey(COMPONENT_KEY);
|
||||
if (consumeRestoredStateForKey == null) {
|
||||
return;
|
||||
}
|
||||
ArrayList<String> stringArrayList = consumeRestoredStateForKey.getStringArrayList(CLASSES_KEY);
|
||||
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\"");
|
||||
}
|
||||
Iterator<String> it = stringArrayList.iterator();
|
||||
while (it.hasNext()) {
|
||||
reflectiveNew(it.next());
|
||||
}
|
||||
}
|
||||
|
||||
private final void reflectiveNew(String className) {
|
||||
try {
|
||||
Class<? extends U> asSubclass = Class.forName(className, false, Recreator.class.getClassLoader()).asSubclass(SavedStateRegistry.AutoRecreated.class);
|
||||
Intrinsics.checkNotNullExpressionValue(asSubclass, "{\n Class.…class.java)\n }");
|
||||
try {
|
||||
Constructor declaredConstructor = asSubclass.getDeclaredConstructor(new Class[0]);
|
||||
declaredConstructor.setAccessible(true);
|
||||
try {
|
||||
Object newInstance = declaredConstructor.newInstance(new Object[0]);
|
||||
Intrinsics.checkNotNullExpressionValue(newInstance, "{\n constr…wInstance()\n }");
|
||||
((SavedStateRegistry.AutoRecreated) newInstance).onRecreated(this.owner);
|
||||
} catch (Exception e) {
|
||||
throw new RuntimeException("Failed to instantiate " + className, 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 " + className + " wasn't found", e3);
|
||||
}
|
||||
}
|
||||
|
||||
/* compiled from: Recreator.kt */
|
||||
@Metadata(d1 = {"\u0000*\n\u0002\u0018\u0002\n\u0002\u0018\u0002\n\u0000\n\u0002\u0018\u0002\n\u0002\b\u0002\n\u0002\u0010#\n\u0002\u0010\u000e\n\u0000\n\u0002\u0010\u0002\n\u0002\b\u0002\n\u0002\u0018\u0002\n\u0000\b\u0000\u0018\u00002\u00020\u0001B\r\u0012\u0006\u0010\u0002\u001a\u00020\u0003¢\u0006\u0002\u0010\u0004J\u000e\u0010\b\u001a\u00020\t2\u0006\u0010\n\u001a\u00020\u0007J\b\u0010\u000b\u001a\u00020\fH\u0016R\u0014\u0010\u0005\u001a\b\u0012\u0004\u0012\u00020\u00070\u0006X\u0082\u0004¢\u0006\u0002\n\u0000¨\u0006\r"}, d2 = {"Landroidx/savedstate/Recreator$SavedStateProvider;", "Landroidx/savedstate/SavedStateRegistry$SavedStateProvider;", "registry", "Landroidx/savedstate/SavedStateRegistry;", "(Landroidx/savedstate/SavedStateRegistry;)V", "classes", "", "", "add", "", "className", "saveState", "Landroid/os/Bundle;", "savedstate_release"}, k = 1, mv = {1, 8, 0}, xi = 48)
|
||||
public static final class SavedStateProvider implements SavedStateRegistry.SavedStateProvider {
|
||||
private final Set<String> classes;
|
||||
|
||||
public SavedStateProvider(SavedStateRegistry registry) {
|
||||
Intrinsics.checkNotNullParameter(registry, "registry");
|
||||
this.classes = new LinkedHashSet();
|
||||
registry.registerSavedStateProvider(Recreator.COMPONENT_KEY, this);
|
||||
}
|
||||
|
||||
@Override // androidx.savedstate.SavedStateRegistry.SavedStateProvider
|
||||
public Bundle saveState() {
|
||||
Bundle bundle = new Bundle();
|
||||
bundle.putStringArrayList(Recreator.CLASSES_KEY, new ArrayList<>(this.classes));
|
||||
return bundle;
|
||||
}
|
||||
|
||||
public final void add(String className) {
|
||||
Intrinsics.checkNotNullParameter(className, "className");
|
||||
this.classes.add(className);
|
||||
}
|
||||
}
|
||||
}
|
195
02-Easy5/E5/sources/androidx/savedstate/SavedStateRegistry.java
Normal file
195
02-Easy5/E5/sources/androidx/savedstate/SavedStateRegistry.java
Normal file
@ -0,0 +1,195 @@
|
||||
package androidx.savedstate;
|
||||
|
||||
import android.os.Bundle;
|
||||
import androidx.arch.core.internal.SafeIterableMap;
|
||||
import androidx.lifecycle.Lifecycle;
|
||||
import androidx.lifecycle.LifecycleEventObserver;
|
||||
import androidx.lifecycle.LifecycleOwner;
|
||||
import androidx.savedstate.Recreator;
|
||||
import java.util.Iterator;
|
||||
import java.util.Map;
|
||||
import kotlin.Metadata;
|
||||
import kotlin.jvm.internal.DefaultConstructorMarker;
|
||||
import kotlin.jvm.internal.Intrinsics;
|
||||
|
||||
/* compiled from: SavedStateRegistry.kt */
|
||||
@Metadata(d1 = {"\u0000J\n\u0002\u0018\u0002\n\u0002\u0010\u0000\n\u0002\b\u0002\n\u0002\u0010\u000b\n\u0000\n\u0002\u0018\u0002\n\u0002\u0010\u000e\n\u0002\u0018\u0002\n\u0002\b\b\n\u0002\u0018\u0002\n\u0000\n\u0002\u0018\u0002\n\u0002\b\u0004\n\u0002\u0010\u0002\n\u0000\n\u0002\u0018\u0002\n\u0002\b\n\n\u0002\u0018\u0002\n\u0002\u0018\u0002\n\u0002\b\u0005\b\u0007\u0018\u0000 )2\u00020\u0001:\u0003()*B\u0007\b\u0000¢\u0006\u0002\u0010\u0002J\u0012\u0010\u0014\u001a\u0004\u0018\u00010\u00132\u0006\u0010\u0015\u001a\u00020\u0007H\u0007J\u0010\u0010\u0016\u001a\u0004\u0018\u00010\b2\u0006\u0010\u0015\u001a\u00020\u0007J\u0015\u0010\u0017\u001a\u00020\u00182\u0006\u0010\u0019\u001a\u00020\u001aH\u0001¢\u0006\u0002\b\u001bJ\u0017\u0010\u001c\u001a\u00020\u00182\b\u0010\u001d\u001a\u0004\u0018\u00010\u0013H\u0001¢\u0006\u0002\b\u001eJ\u0010\u0010\u001f\u001a\u00020\u00182\u0006\u0010 \u001a\u00020\u0013H\u0007J\u0018\u0010!\u001a\u00020\u00182\u0006\u0010\u0015\u001a\u00020\u00072\u0006\u0010\"\u001a\u00020\bH\u0007J\u0018\u0010#\u001a\u00020\u00182\u000e\u0010$\u001a\n\u0012\u0006\b\u0001\u0012\u00020&0%H\u0007J\u0010\u0010'\u001a\u00020\u00182\u0006\u0010\u0015\u001a\u00020\u0007H\u0007R\u000e\u0010\u0003\u001a\u00020\u0004X\u0082\u000e¢\u0006\u0002\n\u0000R\u001a\u0010\u0005\u001a\u000e\u0012\u0004\u0012\u00020\u0007\u0012\u0004\u0012\u00020\b0\u0006X\u0082\u0004¢\u0006\u0002\n\u0000R\u001a\u0010\t\u001a\u00020\u0004X\u0080\u000e¢\u0006\u000e\n\u0000\u001a\u0004\b\n\u0010\u000b\"\u0004\b\f\u0010\rR \u0010\u000f\u001a\u00020\u00042\u0006\u0010\u000e\u001a\u00020\u00048G@BX\u0086\u000e¢\u0006\b\n\u0000\u001a\u0004\b\u000f\u0010\u000bR\u0010\u0010\u0010\u001a\u0004\u0018\u00010\u0011X\u0082\u000e¢\u0006\u0002\n\u0000R\u0010\u0010\u0012\u001a\u0004\u0018\u00010\u0013X\u0082\u000e¢\u0006\u0002\n\u0000¨\u0006+"}, d2 = {"Landroidx/savedstate/SavedStateRegistry;", "", "()V", "attached", "", "components", "Landroidx/arch/core/internal/SafeIterableMap;", "", "Landroidx/savedstate/SavedStateRegistry$SavedStateProvider;", "isAllowingSavingState", "isAllowingSavingState$savedstate_release", "()Z", "setAllowingSavingState$savedstate_release", "(Z)V", "<set-?>", "isRestored", "recreatorProvider", "Landroidx/savedstate/Recreator$SavedStateProvider;", "restoredState", "Landroid/os/Bundle;", "consumeRestoredStateForKey", "key", "getSavedStateProvider", "performAttach", "", "lifecycle", "Landroidx/lifecycle/Lifecycle;", "performAttach$savedstate_release", "performRestore", "savedState", "performRestore$savedstate_release", "performSave", "outBundle", "registerSavedStateProvider", "provider", "runOnNextRecreation", "clazz", "Ljava/lang/Class;", "Landroidx/savedstate/SavedStateRegistry$AutoRecreated;", "unregisterSavedStateProvider", "AutoRecreated", "Companion", "SavedStateProvider", "savedstate_release"}, k = 1, mv = {1, 8, 0}, xi = 48)
|
||||
/* loaded from: classes.dex */
|
||||
public final class SavedStateRegistry {
|
||||
private static final Companion Companion = new Companion(null);
|
||||
|
||||
@Deprecated
|
||||
private static final String SAVED_COMPONENTS_KEY = "androidx.lifecycle.BundlableSavedStateRegistry.key";
|
||||
private boolean attached;
|
||||
private final SafeIterableMap<String, SavedStateProvider> components = new SafeIterableMap<>();
|
||||
private boolean isAllowingSavingState = true;
|
||||
private boolean isRestored;
|
||||
private Recreator.SavedStateProvider recreatorProvider;
|
||||
private Bundle restoredState;
|
||||
|
||||
/* compiled from: SavedStateRegistry.kt */
|
||||
@Metadata(d1 = {"\u0000\u0016\n\u0002\u0018\u0002\n\u0002\u0010\u0000\n\u0000\n\u0002\u0010\u0002\n\u0000\n\u0002\u0018\u0002\n\u0000\bf\u0018\u00002\u00020\u0001J\u0010\u0010\u0002\u001a\u00020\u00032\u0006\u0010\u0004\u001a\u00020\u0005H&ø\u0001\u0000\u0082\u0002\u0006\n\u0004\b!0\u0001¨\u0006\u0006À\u0006\u0001"}, d2 = {"Landroidx/savedstate/SavedStateRegistry$AutoRecreated;", "", "onRecreated", "", "owner", "Landroidx/savedstate/SavedStateRegistryOwner;", "savedstate_release"}, k = 1, mv = {1, 8, 0}, xi = 48)
|
||||
public interface AutoRecreated {
|
||||
void onRecreated(SavedStateRegistryOwner owner);
|
||||
}
|
||||
|
||||
/* compiled from: SavedStateRegistry.kt */
|
||||
@Metadata(d1 = {"\u0000\u0010\n\u0002\u0018\u0002\n\u0002\u0010\u0000\n\u0000\n\u0002\u0018\u0002\n\u0000\bæ\u0080\u0001\u0018\u00002\u00020\u0001J\b\u0010\u0002\u001a\u00020\u0003H&ø\u0001\u0000\u0082\u0002\u0006\n\u0004\b!0\u0001¨\u0006\u0004À\u0006\u0001"}, d2 = {"Landroidx/savedstate/SavedStateRegistry$SavedStateProvider;", "", "saveState", "Landroid/os/Bundle;", "savedstate_release"}, k = 1, mv = {1, 8, 0}, xi = 48)
|
||||
public interface SavedStateProvider {
|
||||
Bundle saveState();
|
||||
}
|
||||
|
||||
/* renamed from: isAllowingSavingState$savedstate_release, reason: from getter */
|
||||
public final boolean getIsAllowingSavingState() {
|
||||
return this.isAllowingSavingState;
|
||||
}
|
||||
|
||||
/* renamed from: isRestored, reason: from getter */
|
||||
public final boolean getIsRestored() {
|
||||
return this.isRestored;
|
||||
}
|
||||
|
||||
public final void setAllowingSavingState$savedstate_release(boolean z) {
|
||||
this.isAllowingSavingState = z;
|
||||
}
|
||||
|
||||
public final Bundle consumeRestoredStateForKey(String key) {
|
||||
Intrinsics.checkNotNullParameter(key, "key");
|
||||
if (!this.isRestored) {
|
||||
throw new IllegalStateException("You can consumeRestoredStateForKey only after super.onCreate of corresponding component".toString());
|
||||
}
|
||||
Bundle bundle = this.restoredState;
|
||||
if (bundle == null) {
|
||||
return null;
|
||||
}
|
||||
Bundle bundle2 = bundle != null ? bundle.getBundle(key) : null;
|
||||
Bundle bundle3 = this.restoredState;
|
||||
if (bundle3 != null) {
|
||||
bundle3.remove(key);
|
||||
}
|
||||
Bundle bundle4 = this.restoredState;
|
||||
if (bundle4 == null || bundle4.isEmpty()) {
|
||||
this.restoredState = null;
|
||||
}
|
||||
return bundle2;
|
||||
}
|
||||
|
||||
public final void registerSavedStateProvider(String key, SavedStateProvider provider) {
|
||||
Intrinsics.checkNotNullParameter(key, "key");
|
||||
Intrinsics.checkNotNullParameter(provider, "provider");
|
||||
if (this.components.putIfAbsent(key, provider) != null) {
|
||||
throw new IllegalArgumentException("SavedStateProvider with the given key is already registered".toString());
|
||||
}
|
||||
}
|
||||
|
||||
public final SavedStateProvider getSavedStateProvider(String key) {
|
||||
Intrinsics.checkNotNullParameter(key, "key");
|
||||
Iterator<Map.Entry<String, SavedStateProvider>> it = this.components.iterator();
|
||||
while (it.hasNext()) {
|
||||
Map.Entry<String, SavedStateProvider> components = it.next();
|
||||
Intrinsics.checkNotNullExpressionValue(components, "components");
|
||||
String key2 = components.getKey();
|
||||
SavedStateProvider value = components.getValue();
|
||||
if (Intrinsics.areEqual(key2, key)) {
|
||||
return value;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public final void unregisterSavedStateProvider(String key) {
|
||||
Intrinsics.checkNotNullParameter(key, "key");
|
||||
this.components.remove(key);
|
||||
}
|
||||
|
||||
public final void runOnNextRecreation(Class<? extends AutoRecreated> clazz) {
|
||||
Intrinsics.checkNotNullParameter(clazz, "clazz");
|
||||
if (!this.isAllowingSavingState) {
|
||||
throw new IllegalStateException("Can not perform this action after onSaveInstanceState".toString());
|
||||
}
|
||||
Recreator.SavedStateProvider savedStateProvider = this.recreatorProvider;
|
||||
if (savedStateProvider == null) {
|
||||
savedStateProvider = new Recreator.SavedStateProvider(this);
|
||||
}
|
||||
this.recreatorProvider = savedStateProvider;
|
||||
try {
|
||||
clazz.getDeclaredConstructor(new Class[0]);
|
||||
Recreator.SavedStateProvider savedStateProvider2 = this.recreatorProvider;
|
||||
if (savedStateProvider2 != null) {
|
||||
String name = clazz.getName();
|
||||
Intrinsics.checkNotNullExpressionValue(name, "clazz.name");
|
||||
savedStateProvider2.add(name);
|
||||
}
|
||||
} catch (NoSuchMethodException e) {
|
||||
throw new IllegalArgumentException("Class " + clazz.getSimpleName() + " must have default constructor in order to be automatically recreated", e);
|
||||
}
|
||||
}
|
||||
|
||||
public final void performAttach$savedstate_release(Lifecycle lifecycle) {
|
||||
Intrinsics.checkNotNullParameter(lifecycle, "lifecycle");
|
||||
if (!(!this.attached)) {
|
||||
throw new IllegalStateException("SavedStateRegistry was already attached.".toString());
|
||||
}
|
||||
lifecycle.addObserver(new LifecycleEventObserver() { // from class: androidx.savedstate.SavedStateRegistry$$ExternalSyntheticLambda0
|
||||
@Override // androidx.lifecycle.LifecycleEventObserver
|
||||
public final void onStateChanged(LifecycleOwner lifecycleOwner, Lifecycle.Event event) {
|
||||
SavedStateRegistry.performAttach$lambda$4(SavedStateRegistry.this, lifecycleOwner, event);
|
||||
}
|
||||
});
|
||||
this.attached = true;
|
||||
}
|
||||
|
||||
/* JADX INFO: Access modifiers changed from: private */
|
||||
public static final void performAttach$lambda$4(SavedStateRegistry this$0, LifecycleOwner lifecycleOwner, Lifecycle.Event event) {
|
||||
Intrinsics.checkNotNullParameter(this$0, "this$0");
|
||||
Intrinsics.checkNotNullParameter(lifecycleOwner, "<anonymous parameter 0>");
|
||||
Intrinsics.checkNotNullParameter(event, "event");
|
||||
if (event == Lifecycle.Event.ON_START) {
|
||||
this$0.isAllowingSavingState = true;
|
||||
} else if (event == Lifecycle.Event.ON_STOP) {
|
||||
this$0.isAllowingSavingState = false;
|
||||
}
|
||||
}
|
||||
|
||||
public final void performRestore$savedstate_release(Bundle savedState) {
|
||||
if (!this.attached) {
|
||||
throw new IllegalStateException("You must call performAttach() before calling performRestore(Bundle).".toString());
|
||||
}
|
||||
if (!(!this.isRestored)) {
|
||||
throw new IllegalStateException("SavedStateRegistry was already restored.".toString());
|
||||
}
|
||||
this.restoredState = savedState != null ? savedState.getBundle(SAVED_COMPONENTS_KEY) : null;
|
||||
this.isRestored = true;
|
||||
}
|
||||
|
||||
public final void performSave(Bundle outBundle) {
|
||||
Intrinsics.checkNotNullParameter(outBundle, "outBundle");
|
||||
Bundle bundle = new Bundle();
|
||||
Bundle bundle2 = this.restoredState;
|
||||
if (bundle2 != null) {
|
||||
bundle.putAll(bundle2);
|
||||
}
|
||||
SafeIterableMap<String, SavedStateProvider>.IteratorWithAdditions iteratorWithAdditions = this.components.iteratorWithAdditions();
|
||||
Intrinsics.checkNotNullExpressionValue(iteratorWithAdditions, "this.components.iteratorWithAdditions()");
|
||||
SafeIterableMap<String, SavedStateProvider>.IteratorWithAdditions iteratorWithAdditions2 = iteratorWithAdditions;
|
||||
while (iteratorWithAdditions2.hasNext()) {
|
||||
Map.Entry next = iteratorWithAdditions2.next();
|
||||
bundle.putBundle((String) next.getKey(), ((SavedStateProvider) next.getValue()).saveState());
|
||||
}
|
||||
if (bundle.isEmpty()) {
|
||||
return;
|
||||
}
|
||||
outBundle.putBundle(SAVED_COMPONENTS_KEY, bundle);
|
||||
}
|
||||
|
||||
/* compiled from: SavedStateRegistry.kt */
|
||||
@Metadata(d1 = {"\u0000\u0012\n\u0002\u0018\u0002\n\u0002\u0010\u0000\n\u0002\b\u0002\n\u0002\u0010\u000e\n\u0000\b\u0082\u0003\u0018\u00002\u00020\u0001B\u0007\b\u0002¢\u0006\u0002\u0010\u0002R\u000e\u0010\u0003\u001a\u00020\u0004X\u0082T¢\u0006\u0002\n\u0000¨\u0006\u0005"}, d2 = {"Landroidx/savedstate/SavedStateRegistry$Companion;", "", "()V", "SAVED_COMPONENTS_KEY", "", "savedstate_release"}, k = 1, mv = {1, 8, 0}, xi = 48)
|
||||
private static final class Companion {
|
||||
public /* synthetic */ Companion(DefaultConstructorMarker defaultConstructorMarker) {
|
||||
this();
|
||||
}
|
||||
|
||||
private Companion() {
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,81 @@
|
||||
package androidx.savedstate;
|
||||
|
||||
import android.os.Bundle;
|
||||
import androidx.lifecycle.Lifecycle;
|
||||
import kotlin.Metadata;
|
||||
import kotlin.jvm.JvmStatic;
|
||||
import kotlin.jvm.internal.DefaultConstructorMarker;
|
||||
import kotlin.jvm.internal.Intrinsics;
|
||||
|
||||
/* compiled from: SavedStateRegistryController.kt */
|
||||
@Metadata(d1 = {"\u00000\n\u0002\u0018\u0002\n\u0002\u0010\u0000\n\u0000\n\u0002\u0018\u0002\n\u0002\b\u0002\n\u0002\u0010\u000b\n\u0000\n\u0002\u0018\u0002\n\u0002\b\u0003\n\u0002\u0010\u0002\n\u0002\b\u0002\n\u0002\u0018\u0002\n\u0002\b\u0004\u0018\u0000 \u00122\u00020\u0001:\u0001\u0012B\u000f\b\u0002\u0012\u0006\u0010\u0002\u001a\u00020\u0003¢\u0006\u0002\u0010\u0004J\b\u0010\u000b\u001a\u00020\fH\u0007J\u0012\u0010\r\u001a\u00020\f2\b\u0010\u000e\u001a\u0004\u0018\u00010\u000fH\u0007J\u0010\u0010\u0010\u001a\u00020\f2\u0006\u0010\u0011\u001a\u00020\u000fH\u0007R\u000e\u0010\u0005\u001a\u00020\u0006X\u0082\u000e¢\u0006\u0002\n\u0000R\u000e\u0010\u0002\u001a\u00020\u0003X\u0082\u0004¢\u0006\u0002\n\u0000R\u0011\u0010\u0007\u001a\u00020\b¢\u0006\b\n\u0000\u001a\u0004\b\t\u0010\n¨\u0006\u0013"}, d2 = {"Landroidx/savedstate/SavedStateRegistryController;", "", "owner", "Landroidx/savedstate/SavedStateRegistryOwner;", "(Landroidx/savedstate/SavedStateRegistryOwner;)V", "attached", "", "savedStateRegistry", "Landroidx/savedstate/SavedStateRegistry;", "getSavedStateRegistry", "()Landroidx/savedstate/SavedStateRegistry;", "performAttach", "", "performRestore", "savedState", "Landroid/os/Bundle;", "performSave", "outBundle", "Companion", "savedstate_release"}, k = 1, mv = {1, 8, 0}, xi = 48)
|
||||
/* loaded from: classes.dex */
|
||||
public final class SavedStateRegistryController {
|
||||
|
||||
/* renamed from: Companion, reason: from kotlin metadata */
|
||||
public static final Companion INSTANCE = new Companion(null);
|
||||
private boolean attached;
|
||||
private final SavedStateRegistryOwner owner;
|
||||
private final SavedStateRegistry savedStateRegistry;
|
||||
|
||||
public /* synthetic */ SavedStateRegistryController(SavedStateRegistryOwner savedStateRegistryOwner, DefaultConstructorMarker defaultConstructorMarker) {
|
||||
this(savedStateRegistryOwner);
|
||||
}
|
||||
|
||||
@JvmStatic
|
||||
public static final SavedStateRegistryController create(SavedStateRegistryOwner savedStateRegistryOwner) {
|
||||
return INSTANCE.create(savedStateRegistryOwner);
|
||||
}
|
||||
|
||||
public final SavedStateRegistry getSavedStateRegistry() {
|
||||
return this.savedStateRegistry;
|
||||
}
|
||||
|
||||
private SavedStateRegistryController(SavedStateRegistryOwner savedStateRegistryOwner) {
|
||||
this.owner = savedStateRegistryOwner;
|
||||
this.savedStateRegistry = new SavedStateRegistry();
|
||||
}
|
||||
|
||||
public final void performAttach() {
|
||||
Lifecycle lifecycle = this.owner.getLifecycle();
|
||||
if (lifecycle.getState() != Lifecycle.State.INITIALIZED) {
|
||||
throw new IllegalStateException("Restarter must be created only during owner's initialization stage".toString());
|
||||
}
|
||||
lifecycle.addObserver(new Recreator(this.owner));
|
||||
this.savedStateRegistry.performAttach$savedstate_release(lifecycle);
|
||||
this.attached = true;
|
||||
}
|
||||
|
||||
public final void performRestore(Bundle savedState) {
|
||||
if (!this.attached) {
|
||||
performAttach();
|
||||
}
|
||||
Lifecycle lifecycle = this.owner.getLifecycle();
|
||||
if (!(!lifecycle.getState().isAtLeast(Lifecycle.State.STARTED))) {
|
||||
throw new IllegalStateException(("performRestore cannot be called when owner is " + lifecycle.getState()).toString());
|
||||
}
|
||||
this.savedStateRegistry.performRestore$savedstate_release(savedState);
|
||||
}
|
||||
|
||||
public final void performSave(Bundle outBundle) {
|
||||
Intrinsics.checkNotNullParameter(outBundle, "outBundle");
|
||||
this.savedStateRegistry.performSave(outBundle);
|
||||
}
|
||||
|
||||
/* compiled from: SavedStateRegistryController.kt */
|
||||
@Metadata(d1 = {"\u0000\u0018\n\u0002\u0018\u0002\n\u0002\u0010\u0000\n\u0002\b\u0002\n\u0002\u0018\u0002\n\u0000\n\u0002\u0018\u0002\n\u0000\b\u0086\u0003\u0018\u00002\u00020\u0001B\u0007\b\u0002¢\u0006\u0002\u0010\u0002J\u0010\u0010\u0003\u001a\u00020\u00042\u0006\u0010\u0005\u001a\u00020\u0006H\u0007¨\u0006\u0007"}, d2 = {"Landroidx/savedstate/SavedStateRegistryController$Companion;", "", "()V", "create", "Landroidx/savedstate/SavedStateRegistryController;", "owner", "Landroidx/savedstate/SavedStateRegistryOwner;", "savedstate_release"}, k = 1, mv = {1, 8, 0}, xi = 48)
|
||||
public static final class Companion {
|
||||
public /* synthetic */ Companion(DefaultConstructorMarker defaultConstructorMarker) {
|
||||
this();
|
||||
}
|
||||
|
||||
private Companion() {
|
||||
}
|
||||
|
||||
@JvmStatic
|
||||
public final SavedStateRegistryController create(SavedStateRegistryOwner owner) {
|
||||
Intrinsics.checkNotNullParameter(owner, "owner");
|
||||
return new SavedStateRegistryController(owner, null);
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,11 @@
|
||||
package androidx.savedstate;
|
||||
|
||||
import androidx.lifecycle.LifecycleOwner;
|
||||
import kotlin.Metadata;
|
||||
|
||||
/* compiled from: SavedStateRegistryOwner.kt */
|
||||
@Metadata(d1 = {"\u0000\u0012\n\u0002\u0018\u0002\n\u0002\u0018\u0002\n\u0000\n\u0002\u0018\u0002\n\u0002\b\u0003\bf\u0018\u00002\u00020\u0001R\u0012\u0010\u0002\u001a\u00020\u0003X¦\u0004¢\u0006\u0006\u001a\u0004\b\u0004\u0010\u0005ø\u0001\u0000\u0082\u0002\u0006\n\u0004\b!0\u0001¨\u0006\u0006À\u0006\u0001"}, d2 = {"Landroidx/savedstate/SavedStateRegistryOwner;", "Landroidx/lifecycle/LifecycleOwner;", "savedStateRegistry", "Landroidx/savedstate/SavedStateRegistry;", "getSavedStateRegistry", "()Landroidx/savedstate/SavedStateRegistry;", "savedstate_release"}, k = 1, mv = {1, 8, 0}, xi = 48)
|
||||
/* loaded from: classes.dex */
|
||||
public interface SavedStateRegistryOwner extends LifecycleOwner {
|
||||
SavedStateRegistry getSavedStateRegistry();
|
||||
}
|
@ -0,0 +1,42 @@
|
||||
package androidx.savedstate;
|
||||
|
||||
import android.view.View;
|
||||
import kotlin.Metadata;
|
||||
import kotlin.jvm.functions.Function1;
|
||||
import kotlin.jvm.internal.Intrinsics;
|
||||
import kotlin.sequences.SequencesKt;
|
||||
|
||||
/* compiled from: ViewTreeSavedStateRegistryOwner.kt */
|
||||
@Metadata(d1 = {"\u0000\u0016\n\u0000\n\u0002\u0018\u0002\n\u0002\u0018\u0002\n\u0002\b\u0002\n\u0002\u0010\u0002\n\u0002\b\u0003\u001a\u0013\u0010\u0000\u001a\u0004\u0018\u00010\u0001*\u00020\u0002H\u0007¢\u0006\u0002\b\u0003\u001a\u001b\u0010\u0004\u001a\u00020\u0005*\u00020\u00022\b\u0010\u0006\u001a\u0004\u0018\u00010\u0001H\u0007¢\u0006\u0002\b\u0007¨\u0006\b"}, d2 = {"findViewTreeSavedStateRegistryOwner", "Landroidx/savedstate/SavedStateRegistryOwner;", "Landroid/view/View;", "get", "setViewTreeSavedStateRegistryOwner", "", "owner", "set", "savedstate_release"}, k = 2, mv = {1, 8, 0}, xi = 48)
|
||||
/* loaded from: classes.dex */
|
||||
public final class ViewTreeSavedStateRegistryOwner {
|
||||
public static final void set(View view, SavedStateRegistryOwner savedStateRegistryOwner) {
|
||||
Intrinsics.checkNotNullParameter(view, "<this>");
|
||||
view.setTag(R.id.view_tree_saved_state_registry_owner, savedStateRegistryOwner);
|
||||
}
|
||||
|
||||
public static final SavedStateRegistryOwner get(View view) {
|
||||
Intrinsics.checkNotNullParameter(view, "<this>");
|
||||
return (SavedStateRegistryOwner) SequencesKt.firstOrNull(SequencesKt.mapNotNull(SequencesKt.generateSequence(view, new Function1<View, View>() { // from class: androidx.savedstate.ViewTreeSavedStateRegistryOwner$findViewTreeSavedStateRegistryOwner$1
|
||||
@Override // kotlin.jvm.functions.Function1
|
||||
public final View invoke(View view2) {
|
||||
Intrinsics.checkNotNullParameter(view2, "view");
|
||||
Object parent = view2.getParent();
|
||||
if (parent instanceof View) {
|
||||
return (View) parent;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}), new Function1<View, SavedStateRegistryOwner>() { // from class: androidx.savedstate.ViewTreeSavedStateRegistryOwner$findViewTreeSavedStateRegistryOwner$2
|
||||
@Override // kotlin.jvm.functions.Function1
|
||||
public final SavedStateRegistryOwner invoke(View view2) {
|
||||
Intrinsics.checkNotNullParameter(view2, "view");
|
||||
Object tag = view2.getTag(R.id.view_tree_saved_state_registry_owner);
|
||||
if (tag instanceof SavedStateRegistryOwner) {
|
||||
return (SavedStateRegistryOwner) tag;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}));
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user