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.lifecycle.Lifecycle$Event;

/* JADX INFO: loaded from: classes.dex */
public class r extends Dialog implements androidx.lifecycle.p, c0, i3.h {

    /* JADX INFO: renamed from: a, reason: collision with root package name */
    public androidx.lifecycle.r f500a;

    /* JADX INFO: renamed from: b, reason: collision with root package name */
    public final i3.g f501b;

    /* JADX INFO: renamed from: c, reason: collision with root package name */
    public final b0 f502c;

    /* JADX WARN: 'super' call moved to the top of the method (can break code semantics) */
    public r(Context context, int i10) {
        super(context, i10);
        nb.g.i(context, "context");
        this.f501b = eb.e.a(this);
        this.f502c = new b0(new l(this, 1));
    }

    public static void a(r rVar) {
        super.onBackPressed();
    }

    @Override // android.app.Dialog
    public void addContentView(View view, ViewGroup.LayoutParams layoutParams) {
        nb.g.i(view, "view");
        c();
        super.addContentView(view, layoutParams);
    }

    public final androidx.lifecycle.r b() {
        androidx.lifecycle.r rVar = this.f500a;
        if (rVar != null) {
            return rVar;
        }
        androidx.lifecycle.r rVar2 = new androidx.lifecycle.r(this);
        this.f500a = rVar2;
        return rVar2;
    }

    public final void c() {
        Window window = getWindow();
        nb.g.f(window);
        View decorView = window.getDecorView();
        nb.g.h(decorView, "window!!.decorView");
        decorView.setTag(m1.a.view_tree_lifecycle_owner, this);
        Window window2 = getWindow();
        nb.g.f(window2);
        View decorView2 = window2.getDecorView();
        nb.g.h(decorView2, "window!!.decorView");
        decorView2.setTag(d0.view_tree_on_back_pressed_dispatcher_owner, this);
        Window window3 = getWindow();
        nb.g.f(window3);
        View decorView3 = window3.getDecorView();
        nb.g.h(decorView3, "window!!.decorView");
        decorView3.setTag(i3.a.view_tree_saved_state_registry_owner, this);
    }

    @Override // androidx.lifecycle.p
    public final androidx.lifecycle.l getLifecycle() {
        return b();
    }

    @Override // androidx.activity.c0
    public final b0 getOnBackPressedDispatcher() {
        return this.f502c;
    }

    @Override // i3.h
    public final i3.f getSavedStateRegistry() {
        return this.f501b.f26535b;
    }

    @Override // android.app.Dialog
    public final void onBackPressed() {
        this.f502c.c();
    }

    @Override // android.app.Dialog
    public void onCreate(Bundle bundle) {
        super.onCreate(bundle);
        if (Build.VERSION.SDK_INT >= 33) {
            OnBackInvokedDispatcher onBackInvokedDispatcher = getOnBackInvokedDispatcher();
            nb.g.h(onBackInvokedDispatcher, "onBackInvokedDispatcher");
            b0 b0Var = this.f502c;
            b0Var.f474e = onBackInvokedDispatcher;
            b0Var.d(b0Var.f476g);
        }
        this.f501b.b(bundle);
        b().e(Lifecycle$Event.ON_CREATE);
    }

    @Override // android.app.Dialog
    public final Bundle onSaveInstanceState() {
        Bundle bundleOnSaveInstanceState = super.onSaveInstanceState();
        nb.g.h(bundleOnSaveInstanceState, "super.onSaveInstanceState()");
        this.f501b.c(bundleOnSaveInstanceState);
        return bundleOnSaveInstanceState;
    }

    @Override // android.app.Dialog
    public void onStart() {
        super.onStart();
        b().e(Lifecycle$Event.ON_RESUME);
    }

    @Override // android.app.Dialog
    public void onStop() {
        b().e(Lifecycle$Event.ON_DESTROY);
        this.f500a = null;
        super.onStop();
    }

    @Override // android.app.Dialog
    public void setContentView(int i10) {
        c();
        super.setContentView(i10);
    }

    @Override // android.app.Dialog
    public void setContentView(View view) {
        nb.g.i(view, "view");
        c();
        super.setContentView(view);
    }

    @Override // android.app.Dialog
    public void setContentView(View view, ViewGroup.LayoutParams layoutParams) {
        nb.g.i(view, "view");
        c();
        super.setContentView(view, layoutParams);
    }
}
