package k;

import android.content.Context;
import android.graphics.Point;
import android.graphics.Rect;
import android.view.Display;
import android.view.Gravity;
import android.view.View;
import android.view.WindowManager;
import android.widget.PopupWindow;
import androidx.annotation.Nullable;

/* JADX INFO: loaded from: classes.dex */
public class z {

    /* JADX INFO: renamed from: a, reason: collision with root package name */
    public final Context f28946a;

    /* JADX INFO: renamed from: b, reason: collision with root package name */
    public final p f28947b;

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

    /* JADX INFO: renamed from: d, reason: collision with root package name */
    public final int f28949d;

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

    /* JADX INFO: renamed from: f, reason: collision with root package name */
    public View f28951f;

    /* JADX INFO: renamed from: h, reason: collision with root package name */
    public boolean f28953h;

    /* JADX INFO: renamed from: i, reason: collision with root package name */
    public a0 f28954i;

    /* JADX INFO: renamed from: j, reason: collision with root package name */
    public x f28955j;

    /* JADX INFO: renamed from: k, reason: collision with root package name */
    public PopupWindow.OnDismissListener f28956k;

    /* JADX INFO: renamed from: g, reason: collision with root package name */
    public int f28952g = 8388611;

    /* JADX INFO: renamed from: l, reason: collision with root package name */
    public final y f28957l = new y(this);

    public z(int i10, int i11, Context context, View view, p pVar, boolean z10) {
        this.f28946a = context;
        this.f28947b = pVar;
        this.f28951f = view;
        this.f28948c = z10;
        this.f28949d = i10;
        this.f28950e = i11;
    }

    public final x a() {
        x g0Var;
        if (this.f28955j == null) {
            Context context = this.f28946a;
            Display defaultDisplay = ((WindowManager) context.getSystemService("window")).getDefaultDisplay();
            Point point = new Point();
            defaultDisplay.getRealSize(point);
            if (Math.min(point.x, point.y) >= context.getResources().getDimensionPixelSize(d.d.abc_cascading_menus_min_smallest_width)) {
                g0Var = new j(this.f28946a, this.f28951f, this.f28949d, this.f28950e, this.f28948c);
            } else {
                Context context2 = this.f28946a;
                p pVar = this.f28947b;
                g0Var = new g0(this.f28949d, this.f28950e, context2, this.f28951f, pVar, this.f28948c);
            }
            g0Var.g(this.f28947b);
            g0Var.m(this.f28957l);
            g0Var.i(this.f28951f);
            g0Var.setCallback(this.f28954i);
            g0Var.j(this.f28953h);
            g0Var.k(this.f28952g);
            this.f28955j = g0Var;
        }
        return this.f28955j;
    }

    public final boolean b() {
        x xVar = this.f28955j;
        return xVar != null && xVar.a();
    }

    public void c() {
        this.f28955j = null;
        PopupWindow.OnDismissListener onDismissListener = this.f28956k;
        if (onDismissListener != null) {
            onDismissListener.onDismiss();
        }
    }

    public final void d(int i10, int i11, boolean z10, boolean z11) {
        x xVarA = a();
        xVarA.n(z11);
        if (z10) {
            if ((Gravity.getAbsoluteGravity(this.f28952g, this.f28951f.getLayoutDirection()) & 7) == 5) {
                i10 -= this.f28951f.getWidth();
            }
            xVarA.l(i10);
            xVarA.o(i11);
            int i12 = (int) ((this.f28946a.getResources().getDisplayMetrics().density * 48.0f) / 2.0f);
            xVarA.f28944a = new Rect(i10 - i12, i11 - i12, i10 + i12, i11 + i12);
        }
        xVarA.e();
    }

    public void setOnDismissListener(@Nullable PopupWindow.OnDismissListener onDismissListener) {
        this.f28956k = onDismissListener;
    }

    public void setPresenterCallback(@Nullable a0 a0Var) {
        this.f28954i = a0Var;
        x xVar = this.f28955j;
        if (xVar != null) {
            xVar.setCallback(a0Var);
        }
    }
}
