package X6FRs_4.KQgRr5e_0.YghfZG_14.XnFJ5_9;

import X6FRs_4.KQgRr5e_0.YghfZG_14.XnFJ5_9.LGe8pk_15;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import androidx.appcompat.view.menu.ListMenuItemView;
import java.util.ArrayList;
/* compiled from: MenuAdapter.java */
/* loaded from: classes.dex */
public class IMuAHx_6 extends BaseAdapter {
    public int KQgRr5e_0 = -1;

    /* renamed from: KQgRr5e_0  reason: collision with other field name */
    public FSaI4_7 f892KQgRr5e_0;

    /* renamed from: KQgRr5e_0  reason: collision with other field name */
    public final LayoutInflater f893KQgRr5e_0;
    public final boolean PGPF6hQ_2;
    public final int QxJ9d_1;

    /* renamed from: QxJ9d_1  reason: collision with other field name */
    public boolean f894QxJ9d_1;

    public IMuAHx_6(FSaI4_7 fSaI4_7, LayoutInflater layoutInflater, boolean z, int i) {
        this.PGPF6hQ_2 = z;
        this.f893KQgRr5e_0 = layoutInflater;
        this.f892KQgRr5e_0 = fSaI4_7;
        this.QxJ9d_1 = i;
        m475KQgRr5e_0();
    }

    public void KQgRr5e_0(boolean z) {
        this.f894QxJ9d_1 = z;
    }

    @Override // android.widget.Adapter
    public int getCount() {
        ArrayList<XnFJ5_9> nonActionItems = this.PGPF6hQ_2 ? this.f892KQgRr5e_0.getNonActionItems() : this.f892KQgRr5e_0.getVisibleItems();
        if (this.KQgRr5e_0 < 0) {
            return nonActionItems.size();
        }
        return nonActionItems.size() - 1;
    }

    @Override // android.widget.Adapter
    public long getItemId(int i) {
        return i;
    }

    @Override // android.widget.Adapter
    public View getView(int i, View view, ViewGroup viewGroup) {
        if (view == null) {
            view = this.f893KQgRr5e_0.inflate(this.QxJ9d_1, viewGroup, false);
        }
        int groupId = getItem(i).getGroupId();
        int i2 = i - 1;
        ListMenuItemView listMenuItemView = (ListMenuItemView) view;
        listMenuItemView.setGroupDividerEnabled(this.f892KQgRr5e_0.isGroupDividerEnabled() && groupId != (i2 >= 0 ? getItem(i2).getGroupId() : groupId));
        LGe8pk_15.KQgRr5e_0 kQgRr5e_0 = (LGe8pk_15.KQgRr5e_0) view;
        if (this.f894QxJ9d_1) {
            listMenuItemView.setForceShowIcon(true);
        }
        kQgRr5e_0.initialize(getItem(i), 0);
        return view;
    }

    @Override // android.widget.BaseAdapter
    public void notifyDataSetChanged() {
        m475KQgRr5e_0();
        super.notifyDataSetChanged();
    }

    public FSaI4_7 KQgRr5e_0() {
        return this.f892KQgRr5e_0;
    }

    @Override // android.widget.Adapter
    /* renamed from: KQgRr5e_0 */
    public XnFJ5_9 getItem(int i) {
        ArrayList<XnFJ5_9> nonActionItems = this.PGPF6hQ_2 ? this.f892KQgRr5e_0.getNonActionItems() : this.f892KQgRr5e_0.getVisibleItems();
        int i2 = this.KQgRr5e_0;
        if (i2 >= 0 && i >= i2) {
            i++;
        }
        return nonActionItems.get(i);
    }

    /* renamed from: KQgRr5e_0  reason: collision with other method in class */
    public void m475KQgRr5e_0() {
        XnFJ5_9 expandedItem = this.f892KQgRr5e_0.getExpandedItem();
        if (expandedItem != null) {
            ArrayList<XnFJ5_9> nonActionItems = this.f892KQgRr5e_0.getNonActionItems();
            int size = nonActionItems.size();
            for (int i = 0; i < size; i++) {
                if (nonActionItems.get(i) == expandedItem) {
                    this.KQgRr5e_0 = i;
                    return;
                }
            }
        }
        this.KQgRr5e_0 = -1;
    }
}
