package androidx.appcompat.widget; import android.content.Context; import android.content.res.Configuration; import android.graphics.drawable.Drawable; import android.os.Build; import android.transition.Transition; import android.view.KeyEvent; import android.view.MenuItem; import android.view.MotionEvent; import android.widget.HeaderViewListAdapter; import android.widget.ListAdapter; import android.widget.PopupWindow; import androidx.appcompat.view.menu.ListMenuItemView; import androidx.appcompat.view.menu.MenuItemImpl; import java.lang.reflect.Method; import o.C15846jAy; import o.C5263bpj; import o.NoP; import o.PUM; /* loaded from: classes.dex */ public final class MenuPopupWindow extends C15846jAy implements PUM { public static Method d; public PUM e; static { try { if (Build.VERSION.SDK_INT <= 28) { d = PopupWindow.class.getDeclaredMethod("setTouchModal", Boolean.TYPE); } } catch (NoSuchMethodException unused) { } } public MenuPopupWindow(Context context, int i, int i2) { super(context, null, i, i2); } @Override // o.C15846jAy public final DropDownListView e(Context context, boolean z) { MenuDropDownListView menuDropDownListView = new MenuDropDownListView(context, z); menuDropDownListView.setHoverListener(this); return menuDropDownListView; } @Override // o.PUM public final void iF_(NoP noP, MenuItem menuItem) { PUM pum = this.e; if (pum != null) { pum.iF_(noP, menuItem); } } @Override // o.PUM public final void iG_(NoP noP, MenuItem menuItem) { PUM pum = this.e; if (pum != null) { pum.iG_(noP, menuItem); } } /* loaded from: classes.dex */ public static class MenuDropDownListView extends DropDownListView { private PUM b; final int c; final int d; private MenuItem i; @Override // androidx.appcompat.widget.DropDownListView public final /* bridge */ /* synthetic */ int e(int i, int i2, int i3, int i4, int i5) { return super.e(i, i2, i3, i4, i5); } @Override // androidx.appcompat.widget.DropDownListView, android.view.ViewGroup, android.view.View public /* bridge */ /* synthetic */ boolean hasFocus() { return super.hasFocus(); } @Override // androidx.appcompat.widget.DropDownListView, android.view.View public /* bridge */ /* synthetic */ boolean hasWindowFocus() { return super.hasWindowFocus(); } @Override // androidx.appcompat.widget.DropDownListView public final /* bridge */ /* synthetic */ boolean iK_(MotionEvent motionEvent, int i) { return super.iK_(motionEvent, i); } @Override // androidx.appcompat.widget.DropDownListView, android.view.View public /* bridge */ /* synthetic */ boolean isFocused() { return super.isFocused(); } @Override // androidx.appcompat.widget.DropDownListView, android.view.View public /* bridge */ /* synthetic */ boolean isInTouchMode() { return super.isInTouchMode(); } @Override // androidx.appcompat.widget.DropDownListView, android.widget.AbsListView, android.view.View public /* bridge */ /* synthetic */ boolean onTouchEvent(MotionEvent motionEvent) { return super.onTouchEvent(motionEvent); } @Override // androidx.appcompat.widget.DropDownListView, android.widget.AbsListView public /* bridge */ /* synthetic */ void setSelector(Drawable drawable) { super.setSelector(drawable); } public MenuDropDownListView(Context context, boolean z) { super(context, z); if (1 == HBt.iL_(context.getResources().getConfiguration())) { this.c = 21; this.d = 22; } else { this.c = 22; this.d = 21; } } @Override // android.widget.ListView, android.widget.AbsListView, android.view.View, android.view.KeyEvent.Callback public boolean onKeyDown(int i, KeyEvent keyEvent) { C5263bpj c5263bpj; ListMenuItemView listMenuItemView = (ListMenuItemView) getSelectedView(); if (listMenuItemView != null && i == this.c) { if (listMenuItemView.isEnabled() && listMenuItemView.e.hasSubMenu()) { performItemClick(listMenuItemView, getSelectedItemPosition(), getSelectedItemId()); } return true; } if (listMenuItemView != null && i == this.d) { setSelection(-1); ListAdapter adapter = getAdapter(); if (adapter instanceof HeaderViewListAdapter) { c5263bpj = (C5263bpj) ((HeaderViewListAdapter) adapter).getWrappedAdapter(); } else { c5263bpj = (C5263bpj) adapter; } c5263bpj.d.b(false); return true; } return super.onKeyDown(i, keyEvent); } @Override // androidx.appcompat.widget.DropDownListView, android.view.View public boolean onHoverEvent(MotionEvent motionEvent) { C5263bpj c5263bpj; int i; int pointToPosition; int i2; if (this.b != null) { ListAdapter adapter = getAdapter(); if (adapter instanceof HeaderViewListAdapter) { HeaderViewListAdapter headerViewListAdapter = (HeaderViewListAdapter) adapter; i = headerViewListAdapter.getHeadersCount(); c5263bpj = (C5263bpj) headerViewListAdapter.getWrappedAdapter(); } else { c5263bpj = (C5263bpj) adapter; i = 0; } MenuItemImpl item = (motionEvent.getAction() == 10 || (pointToPosition = pointToPosition((int) motionEvent.getX(), (int) motionEvent.getY())) == -1 || (i2 = pointToPosition - i) < 0 || i2 >= c5263bpj.getCount()) ? null : c5263bpj.getItem(i2); MenuItem menuItem = this.i; if (menuItem != item) { NoP noP = c5263bpj.d; if (menuItem != null) { this.b.iG_(noP, menuItem); } this.i = item; if (item != null) { this.b.iF_(noP, item); } } } return super.onHoverEvent(motionEvent); } /* loaded from: classes.dex */ static class HBt { static int iL_(Configuration configuration) { return configuration.getLayoutDirection(); } } public void setHoverListener(PUM pum) { this.b = pum; } } /* loaded from: classes.dex */ public static class RVV { public static void iH_(PopupWindow popupWindow, Transition transition) { popupWindow.setEnterTransition(transition); } public static void iI_(PopupWindow popupWindow, Transition transition) { popupWindow.setExitTransition(transition); } } /* loaded from: classes.dex */ public static class Sts { public static void iJ_(PopupWindow popupWindow, boolean z) { popupWindow.setTouchModal(z); } } }