package androidx.appcompat.view.menu; import android.content.Context; import android.graphics.Point; import android.graphics.Rect; import android.view.Display; import android.view.View; import android.view.WindowManager; import android.widget.PopupWindow; import androidx.appcompat.view.menu.j; import androidx.core.view.n0; import androidx.core.view.s; /* loaded from: classes.dex */ public class i { /* renamed from: a, reason: collision with root package name */ private final Context f664a; /* renamed from: b, reason: collision with root package name */ private final e f665b; /* renamed from: c, reason: collision with root package name */ private final boolean f666c; /* renamed from: d, reason: collision with root package name */ private final int f667d; /* renamed from: e, reason: collision with root package name */ private final int f668e; /* renamed from: f, reason: collision with root package name */ private View f669f; /* renamed from: g, reason: collision with root package name */ private int f670g; /* renamed from: h, reason: collision with root package name */ private boolean f671h; /* renamed from: i, reason: collision with root package name */ private j.a f672i; /* renamed from: j, reason: collision with root package name */ private h f673j; /* renamed from: k, reason: collision with root package name */ private PopupWindow.OnDismissListener f674k; /* renamed from: l, reason: collision with root package name */ private final PopupWindow.OnDismissListener f675l; class a implements PopupWindow.OnDismissListener { a() { } @Override // android.widget.PopupWindow.OnDismissListener public void onDismiss() { i.this.e(); } } public i(Context context, e eVar, View view, boolean z10, int i10) { this(context, eVar, view, z10, i10, 0); } private h a() { Display defaultDisplay = ((WindowManager) this.f664a.getSystemService("window")).getDefaultDisplay(); Point point = new Point(); defaultDisplay.getRealSize(point); h bVar = Math.min(point.x, point.y) >= this.f664a.getResources().getDimensionPixelSize(d.d.f8714a) ? new b(this.f664a, this.f669f, this.f667d, this.f668e, this.f666c) : new l(this.f664a, this.f665b, this.f669f, this.f667d, this.f668e, this.f666c); bVar.l(this.f665b); bVar.u(this.f675l); bVar.p(this.f669f); bVar.g(this.f672i); bVar.r(this.f671h); bVar.s(this.f670g); return bVar; } private void l(int i10, int i11, boolean z10, boolean z11) { h c10 = c(); c10.v(z11); if (z10) { if ((s.b(this.f670g, n0.B(this.f669f)) & 7) == 5) { i10 -= this.f669f.getWidth(); } c10.t(i10); c10.w(i11); int i12 = (int) ((this.f664a.getResources().getDisplayMetrics().density * 48.0f) / 2.0f); c10.q(new Rect(i10 - i12, i11 - i12, i10 + i12, i11 + i12)); } c10.h(); } public void b() { if (d()) { this.f673j.dismiss(); } } public h c() { if (this.f673j == null) { this.f673j = a(); } return this.f673j; } public boolean d() { h hVar = this.f673j; return hVar != null && hVar.a(); } protected void e() { this.f673j = null; PopupWindow.OnDismissListener onDismissListener = this.f674k; if (onDismissListener != null) { onDismissListener.onDismiss(); } } public void f(View view) { this.f669f = view; } public void g(boolean z10) { this.f671h = z10; h hVar = this.f673j; if (hVar != null) { hVar.r(z10); } } public void h(int i10) { this.f670g = i10; } public void i(PopupWindow.OnDismissListener onDismissListener) { this.f674k = onDismissListener; } public void j(j.a aVar) { this.f672i = aVar; h hVar = this.f673j; if (hVar != null) { hVar.g(aVar); } } public void k() { if (!m()) { throw new IllegalStateException("MenuPopupHelper cannot be used without an anchor"); } } public boolean m() { if (d()) { return true; } if (this.f669f == null) { return false; } l(0, 0, false, false); return true; } public boolean n(int i10, int i11) { if (d()) { return true; } if (this.f669f == null) { return false; } l(i10, i11, true, true); return true; } public i(Context context, e eVar, View view, boolean z10, int i10, int i11) { this.f670g = 8388611; this.f675l = new a(); this.f664a = context; this.f665b = eVar; this.f669f = view; this.f666c = z10; this.f667d = i10; this.f668e = i11; } }