package androidx.appcompat.view.menu; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; import android.widget.BaseAdapter; import androidx.appcompat.view.menu.k; import java.util.ArrayList; /* loaded from: classes.dex */ public class d extends BaseAdapter { /* renamed from: a, reason: collision with root package name */ e f600a; /* renamed from: b, reason: collision with root package name */ private int f601b = -1; /* renamed from: c, reason: collision with root package name */ private boolean f602c; /* renamed from: d, reason: collision with root package name */ private final boolean f603d; /* renamed from: e, reason: collision with root package name */ private final LayoutInflater f604e; /* renamed from: f, reason: collision with root package name */ private final int f605f; public d(e eVar, LayoutInflater layoutInflater, boolean z10, int i10) { this.f603d = z10; this.f604e = layoutInflater; this.f600a = eVar; this.f605f = i10; a(); } void a() { g v10 = this.f600a.v(); if (v10 != null) { ArrayList z10 = this.f600a.z(); int size = z10.size(); for (int i10 = 0; i10 < size; i10++) { if (((g) z10.get(i10)) == v10) { this.f601b = i10; return; } } } this.f601b = -1; } public e b() { return this.f600a; } @Override // android.widget.Adapter /* renamed from: c, reason: merged with bridge method [inline-methods] */ public g getItem(int i10) { ArrayList z10 = this.f603d ? this.f600a.z() : this.f600a.E(); int i11 = this.f601b; if (i11 >= 0 && i10 >= i11) { i10++; } return (g) z10.get(i10); } public void d(boolean z10) { this.f602c = z10; } @Override // android.widget.Adapter public int getCount() { return this.f601b < 0 ? (this.f603d ? this.f600a.z() : this.f600a.E()).size() : r0.size() - 1; } @Override // android.widget.Adapter public long getItemId(int i10) { return i10; } @Override // android.widget.Adapter public View getView(int i10, View view, ViewGroup viewGroup) { if (view == null) { view = this.f604e.inflate(this.f605f, viewGroup, false); } int groupId = getItem(i10).getGroupId(); int i11 = i10 - 1; ListMenuItemView listMenuItemView = (ListMenuItemView) view; listMenuItemView.setGroupDividerEnabled(this.f600a.F() && groupId != (i11 >= 0 ? getItem(i11).getGroupId() : groupId)); k.a aVar = (k.a) view; if (this.f602c) { listMenuItemView.setForceShowIcon(true); } aVar.e(getItem(i10), 0); return view; } @Override // android.widget.BaseAdapter public void notifyDataSetChanged() { a(); super.notifyDataSetChanged(); } }