package o; import android.content.Context; import android.os.Bundle; import android.os.Parcelable; import android.util.SparseArray; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; import android.view.WindowManager; import android.widget.AdapterView; import android.widget.BaseAdapter; import androidx.appcompat.view.menu.ExpandedMenuView; import androidx.appcompat.view.menu.MenuItemImpl; import com.pingan.ai.face.common.PaFaceConstants; import java.lang.ref.WeakReference; import java.util.ArrayList; import o.DialogInterfaceC17187ufv; import o.InterfaceC15933jjG; import o.SYO; import o.Sya; /* loaded from: classes.dex */ public final class PEg implements InterfaceC15933jjG, AdapterView.OnItemClickListener { public InterfaceC15933jjG.Sts a; public RVV b; int c; int d; public LayoutInflater e; private int f; NoP g; public ExpandedMenuView h; private int i; private Context j; @Override // o.InterfaceC15933jjG public final boolean c(MenuItemImpl menuItemImpl) { return false; } @Override // o.InterfaceC15933jjG public final boolean d(MenuItemImpl menuItemImpl) { return false; } @Override // o.InterfaceC15933jjG public final boolean e() { return false; } public PEg(Context context, int i) { this(i); this.j = context; this.e = LayoutInflater.from(context); } private PEg(int i) { this.c = i; this.i = 0; } @Override // o.InterfaceC15933jjG public final void a(Context context, NoP noP) { if (this.j != null) { this.j = context; if (this.e == null) { this.e = LayoutInflater.from(context); } } this.g = noP; RVV rvv = this.b; if (rvv != null) { rvv.notifyDataSetChanged(); } } @Override // o.InterfaceC15933jjG public final void a(boolean z) { RVV rvv = this.b; if (rvv != null) { rvv.notifyDataSetChanged(); } } @Override // o.InterfaceC15933jjG public final boolean d(SubMenuC16744qqn subMenuC16744qqn) { if (!subMenuC16744qqn.hasVisibleItems()) { return false; } mCV mcv = new mCV(subMenuC16744qqn); NoP noP = mcv.d; DialogInterfaceC17187ufv.HBt hBt = new DialogInterfaceC17187ufv.HBt(noP.d); PEg pEg = new PEg(hBt.b.e, SYO.ojQ.abc_list_menu_item_layout); mcv.e = pEg; pEg.a = mcv; NoP noP2 = mcv.d; PEg pEg2 = mcv.e; Context context = noP2.d; noP2.r.add(new WeakReference<>(pEg2)); pEg2.a(context, noP2); noP2.f = true; PEg pEg3 = mcv.e; if (pEg3.b == null) { pEg3.b = new RVV(pEg3); } hBt.b.a = pEg3.b; hBt.b.x = mcv; View view = noP.h; if (view != null) { hBt.b.f = view; } else { hBt.b.h = noP.i; hBt.b.C = noP.j; } hBt.b.u = mcv; DialogInterfaceC17187ufv b = hBt.b(); mcv.c = b; b.setOnDismissListener(mcv); WindowManager.LayoutParams attributes = mcv.c.getWindow().getAttributes(); attributes.type = PaFaceConstants.MotionType.BLINK_EYE; attributes.flags |= 131072; mcv.c.show(); InterfaceC15933jjG.Sts sts = this.a; if (sts != null) { sts.d(subMenuC16744qqn); } return true; } @Override // o.InterfaceC15933jjG public final void b(NoP noP, boolean z) { InterfaceC15933jjG.Sts sts = this.a; if (sts != null) { sts.e(noP, z); } } @Override // android.widget.AdapterView.OnItemClickListener public final void onItemClick(AdapterView adapterView, View view, int i, long j) { this.g.eM_(this.b.getItem(i), this, 0); } @Override // o.InterfaceC15933jjG public final Parcelable Kn_() { if (this.h == null) { return null; } Bundle bundle = new Bundle(); SparseArray sparseArray = new SparseArray<>(); ExpandedMenuView expandedMenuView = this.h; if (expandedMenuView != null) { expandedMenuView.saveHierarchyState(sparseArray); } bundle.putSparseParcelableArray("android:menu:list", sparseArray); return bundle; } @Override // o.InterfaceC15933jjG public final void Km_(Parcelable parcelable) { SparseArray sparseParcelableArray = ((Bundle) parcelable).getSparseParcelableArray("android:menu:list"); if (sparseParcelableArray != null) { this.h.restoreHierarchyState(sparseParcelableArray); } } /* loaded from: classes.dex */ public class RVV extends BaseAdapter { private int c = -1; final PEg d; @Override // android.widget.Adapter public final long getItemId(int i) { return i; } public RVV(PEg pEg) { this.d = pEg; a(); } @Override // android.widget.Adapter public final int getCount() { NoP noP = this.d.g; noP.a(); int size = noP.m.size() - this.d.d; return this.c < 0 ? size : size - 1; } @Override // android.widget.Adapter /* renamed from: b, reason: merged with bridge method [inline-methods] */ public final MenuItemImpl getItem(int i) { NoP noP = this.d.g; noP.a(); ArrayList arrayList = noP.m; int i2 = i + this.d.d; int i3 = this.c; if (i3 >= 0 && i2 >= i3) { i2++; } return arrayList.get(i2); } @Override // android.widget.Adapter public final View getView(int i, View view, ViewGroup viewGroup) { if (view == null) { view = this.d.e.inflate(this.d.c, viewGroup, false); } ((Sya.HBt) view).c(getItem(i)); return view; } private void a() { MenuItemImpl menuItemImpl = this.d.g.b; if (menuItemImpl != null) { NoP noP = this.d.g; noP.a(); ArrayList arrayList = noP.m; int size = arrayList.size(); for (int i = 0; i < size; i++) { if (arrayList.get(i) == menuItemImpl) { this.c = i; return; } } } this.c = -1; } @Override // android.widget.BaseAdapter public final void notifyDataSetChanged() { a(); super.notifyDataSetChanged(); } } @Override // o.InterfaceC15933jjG public final void c(InterfaceC15933jjG.Sts sts) { this.a = sts; } @Override // o.InterfaceC15933jjG public final int a() { return this.f; } }