- 28,932 files - Full Java source code - Smali files - Resources Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
51 lines
2.0 KiB
Java
51 lines
2.0 KiB
Java
package androidx.lifecycle;
|
|
|
|
import androidx.lifecycle.Lifecycle;
|
|
import androidx.savedstate.SavedStateRegistry;
|
|
import kotlin.jvm.internal.Intrinsics;
|
|
import kotlin.jvm.internal.SourceDebugExtension;
|
|
|
|
@SourceDebugExtension({"SMAP\nSavedStateHandleController.kt\nKotlin\n*S Kotlin\n*F\n+ 1 SavedStateHandleController.kt\nandroidx/lifecycle/SavedStateHandleController\n+ 2 fake.kt\nkotlin/jvm/internal/FakeKt\n*L\n1#1,41:1\n1#2:42\n*E\n"})
|
|
/* loaded from: classes.dex */
|
|
public final class SavedStateHandleController implements LifecycleEventObserver {
|
|
private final SavedStateHandle handle;
|
|
private boolean isAttached;
|
|
private final String key;
|
|
|
|
public final SavedStateHandle getHandle() {
|
|
return this.handle;
|
|
}
|
|
|
|
public final boolean isAttached() {
|
|
return this.isAttached;
|
|
}
|
|
|
|
public SavedStateHandleController(String key, SavedStateHandle handle) {
|
|
Intrinsics.checkNotNullParameter(key, "key");
|
|
Intrinsics.checkNotNullParameter(handle, "handle");
|
|
this.key = key;
|
|
this.handle = handle;
|
|
}
|
|
|
|
public final void attachToLifecycle(SavedStateRegistry registry, Lifecycle lifecycle) {
|
|
Intrinsics.checkNotNullParameter(registry, "registry");
|
|
Intrinsics.checkNotNullParameter(lifecycle, "lifecycle");
|
|
if (!(!this.isAttached)) {
|
|
throw new IllegalStateException("Already attached to lifecycleOwner".toString());
|
|
}
|
|
this.isAttached = true;
|
|
lifecycle.addObserver(this);
|
|
registry.registerSavedStateProvider(this.key, this.handle.savedStateProvider());
|
|
}
|
|
|
|
@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_DESTROY) {
|
|
this.isAttached = false;
|
|
source.getLifecycle().removeObserver(this);
|
|
}
|
|
}
|
|
}
|