package o;

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 com.google.android.gms.common.R;

/* compiled from: r8-map-id-3b7cc9102578c509342fa2f0fabed2bfc72239cd258d579fc679bfcbc198b048 */
/* loaded from: classes.dex */
public class WO {
    public final Context a;
    public final CO b;
    public final boolean c;
    public final int d;
    public View e;
    public boolean g;
    public InterfaceC0998dP h;
    public UO i;
    public PopupWindow.OnDismissListener j;
    public int f = 8388611;
    public final VO k = new VO(this);

    public WO(Context context, CO co, View view, boolean z, int i, int i2) {
        this.a = context;
        this.b = co;
        this.e = view;
        this.c = z;
        this.d = i;
    }

    public final UO a() {
        UO viewOnKeyListenerC2248qa0;
        if (this.i == null) {
            Context context = this.a;
            Display defaultDisplay = ((WindowManager) context.getSystemService("window")).getDefaultDisplay();
            Point point = new Point();
            defaultDisplay.getRealSize(point);
            if (Math.min(point.x, point.y) >= context.getResources().getDimensionPixelSize(R.dimen.abc_cascading_menus_min_smallest_width)) {
                viewOnKeyListenerC2248qa0 = new ViewOnKeyListenerC0317Mg(context, this.e, this.d, this.c);
            } else {
                viewOnKeyListenerC2248qa0 = new ViewOnKeyListenerC2248qa0(this.a, this.b, this.e, this.d, this.c);
            }
            viewOnKeyListenerC2248qa0.l(this.b);
            viewOnKeyListenerC2248qa0.r(this.k);
            viewOnKeyListenerC2248qa0.n(this.e);
            viewOnKeyListenerC2248qa0.f(this.h);
            viewOnKeyListenerC2248qa0.o(this.g);
            viewOnKeyListenerC2248qa0.p(this.f);
            this.i = viewOnKeyListenerC2248qa0;
        }
        return this.i;
    }

    public final boolean b() {
        UO uo = this.i;
        return uo != null && uo.b();
    }

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

    public final void d(int i, int i2, boolean z, boolean z2) {
        UO uoA = a();
        uoA.s(z2);
        if (z) {
            if ((Gravity.getAbsoluteGravity(this.f, this.e.getLayoutDirection()) & 7) == 5) {
                i -= this.e.getWidth();
            }
            uoA.q(i);
            uoA.t(i2);
            int i3 = (int) ((this.a.getResources().getDisplayMetrics().density * 48.0f) / 2.0f);
            uoA.l = new Rect(i - i3, i2 - i3, i + i3, i2 + i3);
        }
        uoA.e();
    }
}
