package o;

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: r8-map-id-3b7cc9102578c509342fa2f0fabed2bfc72239cd258d579fc679bfcbc198b048 */
/* renamed from: o.zO, reason: case insensitive filesystem */
/* loaded from: classes.dex */
public final class C3089zO extends BaseAdapter {
    public final CO a;
    public int b = -1;
    public boolean c;
    public final boolean d;
    public final LayoutInflater e;
    public final int f;

    public C3089zO(CO co, LayoutInflater layoutInflater, boolean z, int i) {
        this.d = z;
        this.e = layoutInflater;
        this.a = co;
        this.f = i;
        a();
    }

    public final void a() {
        CO co = this.a;
        LO lo = co.v;
        if (lo != null) {
            co.i();
            ArrayList arrayList = co.j;
            int size = arrayList.size();
            for (int i = 0; i < size; i++) {
                if (((LO) arrayList.get(i)) == lo) {
                    this.b = i;
                    return;
                }
            }
        }
        this.b = -1;
    }

    @Override // android.widget.Adapter
    /* renamed from: b, reason: merged with bridge method [inline-methods] */
    public final LO getItem(int i) {
        ArrayList arrayListL;
        boolean z = this.d;
        CO co = this.a;
        if (z) {
            co.i();
            arrayListL = co.j;
        } else {
            arrayListL = co.l();
        }
        int i2 = this.b;
        if (i2 >= 0 && i >= i2) {
            i++;
        }
        return (LO) arrayListL.get(i);
    }

    @Override // android.widget.Adapter
    public final int getCount() {
        ArrayList arrayListL;
        boolean z = this.d;
        CO co = this.a;
        if (z) {
            co.i();
            arrayListL = co.j;
        } else {
            arrayListL = co.l();
        }
        return this.b < 0 ? arrayListL.size() : arrayListL.size() - 1;
    }

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

    @Override // android.widget.Adapter
    public final View getView(int i, View view, ViewGroup viewGroup) {
        boolean z = false;
        if (view == null) {
            view = this.e.inflate(this.f, viewGroup, false);
        }
        int i2 = getItem(i).b;
        int i3 = i - 1;
        int i4 = i3 >= 0 ? getItem(i3).b : i2;
        ListMenuItemView listMenuItemView = (ListMenuItemView) view;
        if (this.a.m() && i2 != i4) {
            z = true;
        }
        listMenuItemView.setGroupDividerEnabled(z);
        InterfaceC1381hP interfaceC1381hP = (InterfaceC1381hP) view;
        if (this.c) {
            listMenuItemView.setForceShowIcon(true);
        }
        interfaceC1381hP.a(getItem(i));
        return view;
    }

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