content: package androidx.appcompat.view.menu;
  
  import android.content.Context;
  import android.graphics.Point;
  import android.graphics.Rect;
  import android.view.Display;
  import android.view.View;
  import android.widget.ListView;
  import android.widget.PopupWindow;
  import androidx.appcompat.R;
  import androidx.appcompat.view.menu.MenuPresenter;
  import androidx.core.view.GravityCompat;
  import androidx.core.view.ViewCompat;
  
  public class MenuPopupHelper implements MenuHelper {
      private static final int TOUCH_EPICENTER_SIZE_DP = 48;
      private View mAnchorView;
      private final Context mContext;
      private int mDropDownGravity;
      private boolean mForceShowIcon;
      private final PopupWindow.OnDismissListener mInternalOnDismissListener;
      private final MenuBuilder mMenu;
      private PopupWindow.OnDismissListener mOnDismissListener;
      private final boolean mOverflowOnly;
      private MenuPopup mPopup;
      private final int mPopupStyleAttr;
      private final int mPopupStyleRes;
      private MenuPresenter.Callback mPresenterCallback;
  
      static class Api17Impl {
          private Api17Impl() {
          }
  
          static void getRealSize(Display display, Point outSize) {
              display.getRealSize(outSize);
          }
      }
  
      public MenuPopupHelper(Context context, MenuBuilder menu) {
          this(context, menu, (View) null, false, R.attr.popupMenuStyle, 0);
      }
  
      public MenuPopupHelper(Context context, MenuBuilder menu, View anchorView) {
          this(context, menu, anchorView, false, R.attr.popupMenuStyle, 0);
      }
  
      public MenuPopupHelper(Context context, MenuBuilder menu, View anchorView, boolean overflowOnly, int popupStyleAttr) {
          this(context, menu, anchorView, overflowOnly, popupStyleAttr, 0);
      }
  
      public MenuPopupHelper(Context context, MenuBuilder menu, View anchorView, boolean overflowOnly, int popupStyleAttr, int popupStyleRes) {
          this.mDropDownGravity = GravityCompat.START;
          this.mInternalOnDismissListener = new PopupWindow.OnDismissListener() {
              public void onDismiss() {
                  MenuPopupHelper.this.onDismiss();
              }
          };
          this.mContext = context;
          this.mMenu = menu;
          this.mAnchorView = anchorView;
          this.mOverflowOnly = overflowOnly;
          this.mPopupStyleAttr = popupStyleAttr;
          this.mPopupStyleRes = popupStyleRes;
      }
  
      /* JADX WARNING: type inference failed for: r6v2, types: [androidx.appcompat.view.menu.CascadingMenuPopup] */
      /* JADX WARNING: Multi-variable type inference failed */
      /* Code decompiled incorrectly, please refer to instructions dump. */
      private androidx.appcompat.view.menu.MenuPopup createPopup() {
          /*
              r14 = this;
              android.content.Context r0 = r14.mContext
              java.lang.String r1 = "window"
              java.lang.Object r0 = r0.getSystemService(r1)
              android.view.WindowManager r0 = (android.view.WindowManager) r0
              android.view.Display r1 = r0.getDefaultDisplay()
              android.graphics.Point r2 = new android.graphics.Point
              r2.<init>()
              int r3 = android.os.Build.VERSION.SDK_INT
              r4 = 17
              if (r3 < r4) goto L_0x001e
              androidx.appcompat.view.menu.MenuPopupHelper.Api17Impl.getRealSize(r1, r2)
              goto L_0x0021
          L_0x001e:
              r1.getSize(r2)
          L_0x0021:
              int r3 = r2.x
              int r4 = r2.y
              int r3 = java.lang.Math.min(r3, r4)
              android.content.Context r4 = r14.mContext
              android.content.res.Resources r4 = r4.getResources()
              int r5 = androidx.appcompat.R.dimen.abc_cascading_menus_min_smallest_width
              int r4 = r4.getDimensionPixelSize(r5)
              if (r3 < r4) goto L_0x0039
              r5 = 1
              goto L_0x003a
          L_0x0039:
              r5 = 0
          L_0x003a:
              if (r5 == 0) goto L_0x004d
              androidx.appcompat.view.menu.CascadingMenuPopup r12 = new androidx.appcompat.view.menu.CascadingMenuPopup
              android.content.Context r7 = r14.mContext
              android.view.View r8 = r14.mAnchorView
              int r9 = r14.mPopupStyleAttr
              int r10 = r14.mPopupStyleRes
              boolean r11 = r14.mOverflowOnly
              r6 = r12
              r6.<init>(r7, r8, r9, r10, r11)
              goto L_0x005f
          L_0x004d:
              androidx.appcompat.view.menu.StandardMenuPopup r6 = new androidx.appcompat.view.menu.StandardMenuPopup
              android.content.Context r8 = r14.mContext
              androidx.appcompat.view.menu.MenuBuilder r9 = r14.mMenu
              android.view.View r10 = r14.mAnchorView
              int r11 = r14.mPopupStyleAttr
              int r12 = r14.mPopupStyleRes
              boolean r13 = r14.mOverflowOnly
              r7 = r6
              r7.<init>(r8, r9, r10, r11, r12, r13)
          L_0x005f:
              androidx.appcompat.view.menu.MenuBuilder r7 = r14.mMenu
              r6.addMenu(r7)
              android.widget.PopupWindow$OnDismissListener r7 = r14.mInternalOnDismissListener
              r6.setOnDismissListener(r7)
              android.view.View r7 = r14.mAnchorView
              r6.setAnchorView(r7)
              androidx.appcompat.view.menu.MenuPresenter$Callback r7 = r14.mPresenterCallback
              r6.setCallback(r7)
              boolean r7 = r14.mForceShowIcon
              r6.setForceShowIcon(r7)
              int r7 = r14.mDropDownGravity
              r6.setGravity(r7)
              return r6
          */
          throw new UnsupportedOperationException("Method not decompiled: androidx.appcompat.view.menu.MenuPopupHelper.createPopup():androidx.appcompat.view.menu.MenuPopup");
      }
  
      private void showPopup(int xOffset, int yOffset, boolean useOffsets, boolean showTitle) {
          MenuPopup popup = getPopup();
          popup.setShowTitle(showTitle);
          if (useOffsets) {
              if ((GravityCompat.getAbsoluteGravity(this.mDropDownGravity, ViewCompat.getLayoutDirection(this.mAnchorView)) & 7) == 5) {
                  xOffset -= this.mAnchorView.getWidth();
              }
              popup.setHorizontalOffset(xOffset);
              popup.setVerticalOffset(yOffset);
              int i = (int) ((48.0f * this.mContext.getResources().getDisplayMetrics().density) / 2.0f);
              popup.setEpicenterBounds(new Rect(xOffset - i, yOffset - i, xOffset + i, yOffset + i));
          }
          popup.show();
      }
  
      public void dismiss() {
          if (isShowing()) {
              this.mPopup.dismiss();
          }
      }
  
      public int getGravity() {
          return this.mDropDownGravity;
      }
  
      public ListView getListView() {
          return getPopup().getListView();
      }
  
      public MenuPopup getPopup() {
          if (this.mPopup == null) {
              this.mPopup = createPopup();
          }
          return this.mPopup;
      }
  
      public boolean isShowing() {
          MenuPopup menuPopup = this.mPopup;
          return menuPopup != null && menuPopup.isShowing();
      }
  
      /* access modifiers changed from: protected */
      public void onDismiss() {
          this.mPopup = null;
          PopupWindow.OnDismissListener onDismissListener = this.mOnDismissListener;
          if (onDismissListener != null) {
              onDismissListener.onDismiss();
          }
      }
  
      public void setAnchorView(View anchor) {
          this.mAnchorView = anchor;
      }
  
      public void setForceShowIcon(boolean forceShowIcon) {
          this.mForceShowIcon = forceShowIcon;
          MenuPopup menuPopup = this.mPopup;
          if (menuPopup != null) {
              menuPopup.setForceShowIcon(forceShowIcon);
          }
      }
  
      public void setGravity(int gravity) {
          this.mDropDownGravity = gravity;
      }
  
      public void setOnDismissListener(PopupWindow.OnDismissListener listener) {
          this.mOnDismissListener = listener;
      }
  
      public void setPresenterCallback(MenuPresenter.Callback cb) {
          this.mPresenterCallback = cb;
          MenuPopup menuPopup = this.mPopup;
          if (menuPopup != null) {
              menuPopup.setCallback(cb);
          }
      }
  
      public void show() {
          if (!tryShow()) {
              throw new IllegalStateException("MenuPopupHelper cannot be used without an anchor");
          }
      }
  
      public void show(int x, int y) {
          if (!tryShow(x, y)) {
              throw new IllegalStateException("MenuPopupHelper cannot be used without an anchor");
          }
      }
  
      public boolean tryShow() {
          if (isShowing()) {
              return true;
          }
          if (this.mAnchorView == null) {
              return false;
          }
          showPopup(0, 0, false, false);
          return true;
      }
  
      public boolean tryShow(int x, int y) {
          if (isShowing()) {
              return true;
          }
          if (this.mAnchorView == null) {
              return false;
          }
          showPopup(x, y, true, true);
          return true;
      }
  }
  