package m;

import M.J;
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 com.martsnew.tv.R;
import java.lang.reflect.Field;

/* JADX INFO: renamed from: m.m, reason: case insensitive filesystem */
/* JADX INFO: loaded from: classes.dex */
public class C1152m {

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

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

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

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

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

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

    /* JADX INFO: renamed from: h, reason: collision with root package name */
    public InterfaceC1153n f14521h;
    public AbstractC1149j i;

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

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

    /* JADX INFO: renamed from: k, reason: collision with root package name */
    public final C1150k f14523k = new C1150k(this);

    public C1152m(int i, Context context, View view, MenuC1147h menuC1147h, boolean z8) {
        this.f14514a = context;
        this.f14515b = menuC1147h;
        this.f14518e = view;
        this.f14516c = z8;
        this.f14517d = i;
    }

    public final AbstractC1149j a() {
        AbstractC1149j viewOnKeyListenerC1157r;
        if (this.i == null) {
            Context context = this.f14514a;
            Display defaultDisplay = ((WindowManager) context.getSystemService("window")).getDefaultDisplay();
            Point point = new Point();
            AbstractC1151l.a(defaultDisplay, point);
            if (Math.min(point.x, point.y) >= context.getResources().getDimensionPixelSize(R.dimen.abc_cascading_menus_min_smallest_width)) {
                viewOnKeyListenerC1157r = new ViewOnKeyListenerC1144e(context, this.f14518e, this.f14517d, this.f14516c);
            } else {
                View view = this.f14518e;
                Context context2 = this.f14514a;
                boolean z8 = this.f14516c;
                viewOnKeyListenerC1157r = new ViewOnKeyListenerC1157r(this.f14517d, context2, view, this.f14515b, z8);
            }
            viewOnKeyListenerC1157r.l(this.f14515b);
            viewOnKeyListenerC1157r.r(this.f14523k);
            viewOnKeyListenerC1157r.n(this.f14518e);
            viewOnKeyListenerC1157r.j(this.f14521h);
            viewOnKeyListenerC1157r.o(this.f14520g);
            viewOnKeyListenerC1157r.p(this.f14519f);
            this.i = viewOnKeyListenerC1157r;
        }
        return this.i;
    }

    public final boolean b() {
        AbstractC1149j abstractC1149j = this.i;
        return abstractC1149j != null && abstractC1149j.h();
    }

    public void c() {
        this.i = null;
        C1150k c1150k = this.f14522j;
        if (c1150k != null) {
            c1150k.onDismiss();
        }
    }

    public final void d(int i, int i5, boolean z8, boolean z9) {
        AbstractC1149j abstractC1149jA = a();
        abstractC1149jA.s(z9);
        if (z8) {
            int i8 = this.f14519f;
            View view = this.f14518e;
            Field field = J.f4065a;
            if ((Gravity.getAbsoluteGravity(i8, view.getLayoutDirection()) & 7) == 5) {
                i -= this.f14518e.getWidth();
            }
            abstractC1149jA.q(i);
            abstractC1149jA.t(i5);
            int i9 = (int) ((this.f14514a.getResources().getDisplayMetrics().density * 48.0f) / 2.0f);
            abstractC1149jA.f14512q = new Rect(i - i9, i5 - i9, i + i9, i5 + i9);
        }
        abstractC1149jA.c();
    }
}
