示例#1
0
  public void setGroupEnabled(int group, boolean enabled) {
    final int N = mItems.size();

    for (int i = 0; i < N; i++) {
      MenuItemImpl item = mItems.get(i);
      if (item.getGroupId() == group) {
        item.setEnabled(enabled);
      }
    }
  }
示例#2
0
  public void setGroupCheckable(int group, boolean checkable, boolean exclusive) {
    final int N = mItems.size();

    for (int i = 0; i < N; i++) {
      MenuItemImpl item = mItems.get(i);
      if (item.getGroupId() == group) {
        item.setExclusiveCheckable(exclusive);
        item.setCheckable(checkable);
      }
    }
  }
示例#3
0
  void setExclusiveItemChecked(MenuItem item) {
    final int group = item.getGroupId();

    final int N = mItems.size();
    for (int i = 0; i < N; i++) {
      MenuItemImpl curItem = mItems.get(i);
      if (curItem.getGroupId() == group) {
        if (!curItem.isExclusiveCheckable()) continue;
        if (!curItem.isCheckable()) continue;

        // Check the item meant to be checked, uncheck the others (that are in the group)
        curItem.setCheckedInt(curItem == item);
      }
    }
  }
示例#4
0
  public void setGroupVisible(int group, boolean visible) {
    final int N = mItems.size();

    // We handle the notification of items being changed ourselves, so we use setVisibleInt rather
    // than setVisible and at the end notify of items being changed

    boolean changedAtLeastOneItem = false;
    for (int i = 0; i < N; i++) {
      MenuItemImpl item = mItems.get(i);
      if (item.getGroupId() == group) {
        if (item.setVisibleInt(visible)) changedAtLeastOneItem = true;
      }
    }

    if (changedAtLeastOneItem) onItemsChanged(true);
  }
示例#5
0
  public int findGroupIndex(int group, int start) {
    final int size = size();

    if (start < 0) {
      start = 0;
    }

    for (int i = start; i < size; i++) {
      final MenuItemImpl item = mItems.get(i);

      if (item.getGroupId() == group) {
        return i;
      }
    }

    return -1;
  }