package p025i;

import android.content.Context;
import android.graphics.Rect;
import android.view.MenuItem;
import android.view.View;
import android.view.ViewGroup;
import android.widget.AdapterView;
import android.widget.FrameLayout;
import android.widget.HeaderViewListAdapter;
import android.widget.ListAdapter;
import android.widget.PopupWindow;
import androidx.appcompat.view.menu.C0102d;
import androidx.appcompat.view.menu.C0103e;
import androidx.appcompat.view.menu.C0107g;
import androidx.appcompat.view.menu.InterfaceC0112i;

/* renamed from: i.d */
/* loaded from: classes.dex */
public abstract class AbstractC1012d implements InterfaceC1015g, InterfaceC0112i, AdapterView.OnItemClickListener {

    /* renamed from: d */
    public Rect f2544d;

    /* renamed from: o */
    public static int m2393o(ListAdapter listAdapter, ViewGroup viewGroup, Context context, int i) {
        int makeMeasureSpec = View.MeasureSpec.makeMeasureSpec(0, 0);
        int makeMeasureSpec2 = View.MeasureSpec.makeMeasureSpec(0, 0);
        int count = listAdapter.getCount();
        View view = null;
        int i2 = 0;
        int i3 = 0;
        for (int i4 = 0; i4 < count; i4++) {
            int itemViewType = listAdapter.getItemViewType(i4);
            if (itemViewType != i3) {
                view = null;
                i3 = itemViewType;
            }
            if (viewGroup == null) {
                viewGroup = new FrameLayout(context);
            }
            view = listAdapter.getView(i4, view, viewGroup);
            view.measure(makeMeasureSpec, makeMeasureSpec2);
            int measuredWidth = view.getMeasuredWidth();
            if (measuredWidth >= i) {
                return i;
            }
            if (measuredWidth > i2) {
                i2 = measuredWidth;
            }
        }
        return i2;
    }

    /* renamed from: x */
    public static boolean m2384x(C0103e c0103e) {
        int size = c0103e.size();
        for (int i = 0; i < size; i++) {
            MenuItem item = c0103e.getItem(i);
            if (item.isVisible() && item.getIcon() != null) {
                return true;
            }
        }
        return false;
    }

    /* renamed from: y */
    public static C0102d m2383y(ListAdapter listAdapter) {
        return listAdapter instanceof HeaderViewListAdapter ? (C0102d) ((HeaderViewListAdapter) listAdapter).getWrappedAdapter() : (C0102d) listAdapter;
    }

    @Override // androidx.appcompat.view.menu.InterfaceC0112i
    /* renamed from: d */
    public void mo2399d(Context context, C0103e c0103e) {
    }

    @Override // androidx.appcompat.view.menu.InterfaceC0112i
    /* renamed from: e */
    public boolean mo2398e(C0103e c0103e, C0107g c0107g) {
        return false;
    }

    @Override // androidx.appcompat.view.menu.InterfaceC0112i
    /* renamed from: g */
    public boolean mo2397g(C0103e c0103e, C0107g c0107g) {
        return false;
    }

    /* renamed from: l */
    public abstract void mo2396l(C0103e c0103e);

    /* renamed from: m */
    public boolean mo2395m() {
        return true;
    }

    /* renamed from: n */
    public Rect m2394n() {
        return this.f2544d;
    }

    @Override // android.widget.AdapterView.OnItemClickListener
    public void onItemClick(AdapterView<?> adapterView, View view, int i, long j) {
        ListAdapter listAdapter = (ListAdapter) adapterView.getAdapter();
        m2383y(listAdapter).f301d.m4904M((MenuItem) listAdapter.getItem(i), this, mo2395m() ? 0 : 4);
    }

    /* renamed from: p */
    public abstract void mo2392p(View view);

    /* renamed from: q */
    public void m2391q(Rect rect) {
        this.f2544d = rect;
    }

    /* renamed from: r */
    public abstract void mo2390r(boolean z);

    /* renamed from: s */
    public abstract void mo2389s(int i);

    /* renamed from: t */
    public abstract void mo2388t(int i);

    /* renamed from: u */
    public abstract void mo2387u(PopupWindow.OnDismissListener onDismissListener);

    /* renamed from: v */
    public abstract void mo2386v(boolean z);

    /* renamed from: w */
    public abstract void mo2385w(int i);
}