package e;

import android.R;
import android.content.Context;
import android.content.DialogInterface;
import android.os.Bundle;
import android.util.TypedValue;
import android.view.KeyEvent;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import androidx.annotation.IdRes;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;

/* JADX INFO: loaded from: classes.dex */
public class o0 extends androidx.activity.r implements p {

    /* JADX INFO: renamed from: d, reason: collision with root package name */
    public w f25308d;

    /* JADX INFO: renamed from: e, reason: collision with root package name */
    public final n0 f25309e;

    /* JADX WARN: 'super' call moved to the top of the method (can break code semantics) */
    /* JADX WARN: Type inference failed for: r2v1, types: [e.n0] */
    public o0(@NonNull Context context, boolean z10, @Nullable DialogInterface.OnCancelListener onCancelListener) {
        super(context, 0);
        nb.g.i(context, "context");
        final int i10 = 0;
        this.f25309e = new androidx.core.view.u(this) { // from class: e.n0

            /* JADX INFO: renamed from: b, reason: collision with root package name */
            public final /* synthetic */ o0 f25306b;

            {
                this.f25306b = this;
            }

            @Override // androidx.core.view.u
            public final boolean superDispatchKeyEvent(KeyEvent keyEvent) {
                int i11 = i10;
                return this.f25306b.e(keyEvent);
            }
        };
        setCancelable(z10);
        setOnCancelListener(onCancelListener);
    }

    @Override // androidx.activity.r, android.app.Dialog
    public final void addContentView(View view, ViewGroup.LayoutParams layoutParams) {
        c();
        m0 m0Var = (m0) d();
        m0Var.t();
        ((ViewGroup) m0Var.f25277d0.findViewById(R.id.content)).addView(view, layoutParams);
        m0Var.f25289m.a(m0Var.f25287l.getCallback());
    }

    public final w d() {
        if (this.f25308d == null) {
            this.f25308d = w.create(this, this);
        }
        return this.f25308d;
    }

    @Override // android.app.Dialog, android.content.DialogInterface
    public final void dismiss() {
        super.dismiss();
        d().e();
    }

    @Override // android.app.Dialog, android.view.Window.Callback
    public final boolean dispatchKeyEvent(KeyEvent keyEvent) {
        return androidx.core.view.v.dispatchKeyEvent(this.f25309e, getWindow().getDecorView(), this, keyEvent);
    }

    public final boolean e(KeyEvent keyEvent) {
        return super.dispatchKeyEvent(keyEvent);
    }

    @Override // android.app.Dialog
    @Nullable
    public <T extends View> T findViewById(@IdRes int i10) {
        return (T) d().findViewById(i10);
    }

    @Override // android.app.Dialog
    public final void invalidateOptionsMenu() {
        d().b();
    }

    @Override // androidx.activity.r, android.app.Dialog
    public void onCreate(Bundle bundle) {
        m0 m0Var = (m0) d();
        LayoutInflater layoutInflaterFrom = LayoutInflater.from(m0Var.f25285k);
        if (layoutInflaterFrom.getFactory() == null) {
            layoutInflaterFrom.setFactory2(m0Var);
        } else {
            boolean z10 = layoutInflaterFrom.getFactory2() instanceof m0;
        }
        super.onCreate(bundle);
        d().d(bundle);
    }

    @Override // androidx.activity.r, android.app.Dialog
    public final void onStop() {
        super.onStop();
        m0 m0Var = (m0) d();
        m0Var.x();
        c cVar = m0Var.R;
        if (cVar != null) {
            cVar.p(false);
        }
    }

    @Override // e.p
    public final void onSupportActionModeFinished(j.c cVar) {
    }

    @Override // e.p
    public final void onSupportActionModeStarted(j.c cVar) {
    }

    @Override // e.p
    @Nullable
    public j.c onWindowStartingSupportActionMode(j.b bVar) {
        return null;
    }

    @Override // androidx.activity.r, android.app.Dialog
    public void setContentView(int i10) {
        c();
        d().i(i10);
    }

    @Override // android.app.Dialog
    public void setTitle(CharSequence charSequence) {
        super.setTitle(charSequence);
        d().setTitle(charSequence);
    }

    @Override // androidx.activity.r, android.app.Dialog
    public void setContentView(View view) {
        c();
        d().j(view);
    }

    @Override // android.app.Dialog
    public final void setTitle(int i10) {
        super.setTitle(i10);
        d().setTitle(getContext().getString(i10));
    }

    @Override // androidx.activity.r, android.app.Dialog
    public void setContentView(View view, ViewGroup.LayoutParams layoutParams) {
        c();
        d().k(view, layoutParams);
    }

    /* JADX WARN: Type inference failed for: r1v2, types: [e.n0] */
    public o0(Context context, int i10) {
        int i11;
        final int i12 = 1;
        if (i10 == 0) {
            TypedValue typedValue = new TypedValue();
            context.getTheme().resolveAttribute(d.a.dialogTheme, typedValue, true);
            i11 = typedValue.resourceId;
        } else {
            i11 = i10;
        }
        super(context, i11);
        this.f25309e = new androidx.core.view.u(this) { // from class: e.n0

            /* JADX INFO: renamed from: b, reason: collision with root package name */
            public final /* synthetic */ o0 f25306b;

            {
                this.f25306b = this;
            }

            @Override // androidx.core.view.u
            public final boolean superDispatchKeyEvent(KeyEvent keyEvent) {
                int i112 = i12;
                return this.f25306b.e(keyEvent);
            }
        };
        w wVarD = d();
        if (i10 == 0) {
            TypedValue typedValue2 = new TypedValue();
            context.getTheme().resolveAttribute(d.a.dialogTheme, typedValue2, true);
            i10 = typedValue2.resourceId;
        }
        ((m0) wVarD).f25300w0 = i10;
        wVarD.d(null);
    }
}
