package c.a.f.d;

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 c.a.f.d.k;
import com.ifpdos.multiuser.R;
import java.util.WeakHashMap;

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

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

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

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

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

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

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

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

    /* JADX INFO: renamed from: i, reason: collision with root package name */
    public k.a f4895i;

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

    /* JADX INFO: renamed from: g, reason: collision with root package name */
    public int f4893g = 8388611;
    public final PopupWindow.OnDismissListener l = new a();

    public class a implements PopupWindow.OnDismissListener {
        public a() {
        }

        @Override // android.widget.PopupWindow.OnDismissListener
        public void onDismiss() {
            j.this.c();
        }
    }

    public j(Context context, f fVar, View view, boolean z, int i2, int i3) {
        this.f4887a = context;
        this.f4888b = fVar;
        this.f4892f = view;
        this.f4889c = z;
        this.f4890d = i2;
        this.f4891e = i3;
    }

    public i a() {
        if (this.f4896j == null) {
            Display defaultDisplay = ((WindowManager) this.f4887a.getSystemService("window")).getDefaultDisplay();
            Point point = new Point();
            defaultDisplay.getRealSize(point);
            i dVar = Math.min(point.x, point.y) >= this.f4887a.getResources().getDimensionPixelSize(R.dimen.abc_cascading_menus_min_smallest_width) ? new d(this.f4887a, this.f4892f, this.f4890d, this.f4891e, this.f4889c) : new o(this.f4887a, this.f4888b, this.f4892f, this.f4890d, this.f4891e, this.f4889c);
            dVar.m(this.f4888b);
            dVar.s(this.l);
            dVar.o(this.f4892f);
            dVar.l(this.f4895i);
            dVar.p(this.f4894h);
            dVar.q(this.f4893g);
            this.f4896j = dVar;
        }
        return this.f4896j;
    }

    public boolean b() {
        i iVar = this.f4896j;
        return iVar != null && iVar.j();
    }

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

    public void d(k.a aVar) {
        this.f4895i = aVar;
        i iVar = this.f4896j;
        if (iVar != null) {
            iVar.l(aVar);
        }
    }

    public final void e(int i2, int i3, boolean z, boolean z2) {
        i iVarA = a();
        iVarA.t(z2);
        if (z) {
            int i4 = this.f4893g;
            View view = this.f4892f;
            WeakHashMap<View, c.c.i.q> weakHashMap = c.c.i.k.f5288a;
            if ((Gravity.getAbsoluteGravity(i4, view.getLayoutDirection()) & 7) == 5) {
                i2 -= this.f4892f.getWidth();
            }
            iVarA.r(i2);
            iVarA.u(i3);
            int i5 = (int) ((this.f4887a.getResources().getDisplayMetrics().density * 48.0f) / 2.0f);
            iVarA.f4886b = new Rect(i2 - i5, i3 - i5, i2 + i5, i3 + i5);
        }
        iVarA.b();
    }

    public boolean f() {
        if (b()) {
            return true;
        }
        if (this.f4892f == null) {
            return false;
        }
        e(0, 0, false, false);
        return true;
    }
}
