content: 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.MenuView;
  import java.util.ArrayList;
  
  public class MenuAdapter extends BaseAdapter {
      MenuBuilder mAdapterMenu;
      private int mExpandedIndex = -1;
      private boolean mForceShowIcon;
      private final LayoutInflater mInflater;
      private final int mItemLayoutRes;
      private final boolean mOverflowOnly;
  
      public MenuAdapter(MenuBuilder menu, LayoutInflater inflater, boolean overflowOnly, int itemLayoutRes) {
          this.mOverflowOnly = overflowOnly;
          this.mInflater = inflater;
          this.mAdapterMenu = menu;
          this.mItemLayoutRes = itemLayoutRes;
          findExpandedIndex();
      }
  
      /* access modifiers changed from: package-private */
      public void findExpandedIndex() {
          MenuItemImpl expandedItem = this.mAdapterMenu.getExpandedItem();
          if (expandedItem != null) {
              ArrayList<MenuItemImpl> nonActionItems = this.mAdapterMenu.getNonActionItems();
              int size = nonActionItems.size();
              for (int i = 0; i < size; i++) {
                  if (nonActionItems.get(i) == expandedItem) {
                      this.mExpandedIndex = i;
                      return;
                  }
              }
          }
          this.mExpandedIndex = -1;
      }
  
      public MenuBuilder getAdapterMenu() {
          return this.mAdapterMenu;
      }
  
      public int getCount() {
          ArrayList<MenuItemImpl> nonActionItems = this.mOverflowOnly ? this.mAdapterMenu.getNonActionItems() : this.mAdapterMenu.getVisibleItems();
          return this.mExpandedIndex < 0 ? nonActionItems.size() : nonActionItems.size() - 1;
      }
  
      public boolean getForceShowIcon() {
          return this.mForceShowIcon;
      }
  
      public MenuItemImpl getItem(int position) {
          ArrayList<MenuItemImpl> nonActionItems = this.mOverflowOnly ? this.mAdapterMenu.getNonActionItems() : this.mAdapterMenu.getVisibleItems();
          int i = this.mExpandedIndex;
          if (i >= 0 && position >= i) {
              position++;
          }
          return nonActionItems.get(position);
      }
  
      public long getItemId(int position) {
          return (long) position;
      }
  
      public View getView(int position, View convertView, ViewGroup parent) {
          if (convertView == null) {
              convertView = this.mInflater.inflate(this.mItemLayoutRes, parent, false);
          }
          int groupId = getItem(position).getGroupId();
          ((ListMenuItemView) convertView).setGroupDividerEnabled(this.mAdapterMenu.isGroupDividerEnabled() && groupId != (position + -1 >= 0 ? getItem(position + -1).getGroupId() : groupId));
          MenuView.ItemView itemView = (MenuView.ItemView) convertView;
          if (this.mForceShowIcon) {
              ((ListMenuItemView) convertView).setForceShowIcon(true);
          }
          itemView.initialize(getItem(position), 0);
          return convertView;
      }
  
      public void notifyDataSetChanged() {
          findExpandedIndex();
          super.notifyDataSetChanged();
      }
  
      public void setForceShowIcon(boolean forceShow) {
          this.mForceShowIcon = forceShow;
      }
  }
  