- 28,932 files - Full Java source code - Smali files - Resources Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
176 lines
6.8 KiB
Java
176 lines
6.8 KiB
Java
package androidx.activity;
|
|
|
|
import android.app.Dialog;
|
|
import android.content.Context;
|
|
import android.os.Build;
|
|
import android.os.Bundle;
|
|
import android.view.View;
|
|
import android.view.ViewGroup;
|
|
import android.view.Window;
|
|
import android.window.OnBackInvokedDispatcher;
|
|
import androidx.annotation.CallSuper;
|
|
import androidx.annotation.StyleRes;
|
|
import androidx.lifecycle.Lifecycle;
|
|
import androidx.lifecycle.LifecycleOwner;
|
|
import androidx.lifecycle.LifecycleRegistry;
|
|
import androidx.lifecycle.ViewTreeLifecycleOwner;
|
|
import androidx.savedstate.SavedStateRegistry;
|
|
import androidx.savedstate.SavedStateRegistryController;
|
|
import androidx.savedstate.SavedStateRegistryOwner;
|
|
import androidx.savedstate.ViewTreeSavedStateRegistryOwner;
|
|
import kotlin.jvm.internal.DefaultConstructorMarker;
|
|
import kotlin.jvm.internal.Intrinsics;
|
|
|
|
/* loaded from: classes.dex */
|
|
public class ComponentDialog extends Dialog implements LifecycleOwner, OnBackPressedDispatcherOwner, SavedStateRegistryOwner {
|
|
private LifecycleRegistry _lifecycleRegistry;
|
|
private final OnBackPressedDispatcher onBackPressedDispatcher;
|
|
private final SavedStateRegistryController savedStateRegistryController;
|
|
|
|
/* JADX WARN: 'this' call moved to the top of the method (can break code semantics) */
|
|
public ComponentDialog(Context context) {
|
|
this(context, 0, 2, null);
|
|
Intrinsics.checkNotNullParameter(context, "context");
|
|
}
|
|
|
|
public static /* synthetic */ void getOnBackPressedDispatcher$annotations() {
|
|
}
|
|
|
|
@Override // androidx.activity.OnBackPressedDispatcherOwner
|
|
public final OnBackPressedDispatcher getOnBackPressedDispatcher() {
|
|
return this.onBackPressedDispatcher;
|
|
}
|
|
|
|
public /* synthetic */ ComponentDialog(Context context, int i, int i2, DefaultConstructorMarker defaultConstructorMarker) {
|
|
this(context, (i2 & 2) != 0 ? 0 : i);
|
|
}
|
|
|
|
/* JADX WARN: 'super' call moved to the top of the method (can break code semantics) */
|
|
public ComponentDialog(Context context, @StyleRes int i) {
|
|
super(context, i);
|
|
Intrinsics.checkNotNullParameter(context, "context");
|
|
this.savedStateRegistryController = SavedStateRegistryController.Companion.create(this);
|
|
this.onBackPressedDispatcher = new OnBackPressedDispatcher(new Runnable() { // from class: androidx.activity.ComponentDialog$$ExternalSyntheticLambda1
|
|
@Override // java.lang.Runnable
|
|
public final void run() {
|
|
ComponentDialog.onBackPressedDispatcher$lambda$1(ComponentDialog.this);
|
|
}
|
|
});
|
|
}
|
|
|
|
private final LifecycleRegistry getLifecycleRegistry() {
|
|
LifecycleRegistry lifecycleRegistry = this._lifecycleRegistry;
|
|
if (lifecycleRegistry != null) {
|
|
return lifecycleRegistry;
|
|
}
|
|
LifecycleRegistry lifecycleRegistry2 = new LifecycleRegistry(this);
|
|
this._lifecycleRegistry = lifecycleRegistry2;
|
|
return lifecycleRegistry2;
|
|
}
|
|
|
|
@Override // androidx.savedstate.SavedStateRegistryOwner
|
|
public SavedStateRegistry getSavedStateRegistry() {
|
|
return this.savedStateRegistryController.getSavedStateRegistry();
|
|
}
|
|
|
|
@Override // androidx.lifecycle.LifecycleOwner
|
|
public Lifecycle getLifecycle() {
|
|
return getLifecycleRegistry();
|
|
}
|
|
|
|
@Override // android.app.Dialog
|
|
public Bundle onSaveInstanceState() {
|
|
Bundle onSaveInstanceState = super.onSaveInstanceState();
|
|
Intrinsics.checkNotNullExpressionValue(onSaveInstanceState, "super.onSaveInstanceState()");
|
|
this.savedStateRegistryController.performSave(onSaveInstanceState);
|
|
return onSaveInstanceState;
|
|
}
|
|
|
|
@Override // android.app.Dialog
|
|
@CallSuper
|
|
public void onCreate(Bundle bundle) {
|
|
OnBackInvokedDispatcher onBackInvokedDispatcher;
|
|
super.onCreate(bundle);
|
|
if (Build.VERSION.SDK_INT >= 33) {
|
|
OnBackPressedDispatcher onBackPressedDispatcher = this.onBackPressedDispatcher;
|
|
onBackInvokedDispatcher = getOnBackInvokedDispatcher();
|
|
Intrinsics.checkNotNullExpressionValue(onBackInvokedDispatcher, "onBackInvokedDispatcher");
|
|
onBackPressedDispatcher.setOnBackInvokedDispatcher(onBackInvokedDispatcher);
|
|
}
|
|
this.savedStateRegistryController.performRestore(bundle);
|
|
getLifecycleRegistry().handleLifecycleEvent(Lifecycle.Event.ON_CREATE);
|
|
}
|
|
|
|
@Override // android.app.Dialog
|
|
@CallSuper
|
|
public void onStart() {
|
|
super.onStart();
|
|
getLifecycleRegistry().handleLifecycleEvent(Lifecycle.Event.ON_RESUME);
|
|
}
|
|
|
|
@Override // android.app.Dialog
|
|
@CallSuper
|
|
public void onStop() {
|
|
getLifecycleRegistry().handleLifecycleEvent(Lifecycle.Event.ON_DESTROY);
|
|
this._lifecycleRegistry = null;
|
|
super.onStop();
|
|
}
|
|
|
|
/* JADX INFO: Access modifiers changed from: private */
|
|
public static final void onBackPressedDispatcher$lambda$1(ComponentDialog this$0) {
|
|
Intrinsics.checkNotNullParameter(this$0, "this$0");
|
|
super.onBackPressed();
|
|
}
|
|
|
|
@Override // android.app.Dialog
|
|
@CallSuper
|
|
public void onBackPressed() {
|
|
this.onBackPressedDispatcher.onBackPressed();
|
|
}
|
|
|
|
@Override // android.app.Dialog
|
|
public void setContentView(int i) {
|
|
initViewTreeOwners();
|
|
super.setContentView(i);
|
|
}
|
|
|
|
@Override // android.app.Dialog
|
|
public void setContentView(View view) {
|
|
Intrinsics.checkNotNullParameter(view, "view");
|
|
initViewTreeOwners();
|
|
super.setContentView(view);
|
|
}
|
|
|
|
@Override // android.app.Dialog
|
|
public void setContentView(View view, ViewGroup.LayoutParams layoutParams) {
|
|
Intrinsics.checkNotNullParameter(view, "view");
|
|
initViewTreeOwners();
|
|
super.setContentView(view, layoutParams);
|
|
}
|
|
|
|
@Override // android.app.Dialog
|
|
public void addContentView(View view, ViewGroup.LayoutParams layoutParams) {
|
|
Intrinsics.checkNotNullParameter(view, "view");
|
|
initViewTreeOwners();
|
|
super.addContentView(view, layoutParams);
|
|
}
|
|
|
|
private final void initViewTreeOwners() {
|
|
Window window = getWindow();
|
|
Intrinsics.checkNotNull(window);
|
|
View decorView = window.getDecorView();
|
|
Intrinsics.checkNotNullExpressionValue(decorView, "window!!.decorView");
|
|
ViewTreeLifecycleOwner.set(decorView, this);
|
|
Window window2 = getWindow();
|
|
Intrinsics.checkNotNull(window2);
|
|
View decorView2 = window2.getDecorView();
|
|
Intrinsics.checkNotNullExpressionValue(decorView2, "window!!.decorView");
|
|
ViewTreeOnBackPressedDispatcherOwner.set(decorView2, this);
|
|
Window window3 = getWindow();
|
|
Intrinsics.checkNotNull(window3);
|
|
View decorView3 = window3.getDecorView();
|
|
Intrinsics.checkNotNullExpressionValue(decorView3, "window!!.decorView");
|
|
ViewTreeSavedStateRegistryOwner.set(decorView3, this);
|
|
}
|
|
}
|