Java Code Examples for android.view.MenuItem.isVisible()

The following are Jave code examples for showing how to use isVisible() of the android.view.MenuItem class. You can vote up the examples you like. Your votes will be used in our system to get more good examples.
+ Save this method
Example 1
Project: Quran   File: AyahToolBar.java   View Source Code Vote up 6 votes
private void showMenu(Menu menu) {
  if (currentMenu == menu) {
    // no need to re-draw
    return;
  }

  menuLayout.removeAllViews();
  final int count = menu.size();
  for (int i=0; i<count; i++) {
    final MenuItem item = menu.getItem(i);
    if (item.isVisible()) {
      final View view = getMenuItemView(item);
      menuLayout.addView(view);
    }
  }

  currentMenu = menu;
}
 
Example 2
Project: boohee_v5.6   File: MenuPopupHelper.java   View Source Code Vote up 6 votes
public boolean onSubMenuSelected(SubMenuBuilder subMenu) {
    if (subMenu.hasVisibleItems()) {
        MenuPopupHelper subPopup = new MenuPopupHelper(this.mContext, subMenu, this.mAnchorView);
        subPopup.setCallback(this.mPresenterCallback);
        boolean preserveIconSpacing = false;
        int count = subMenu.size();
        for (int i = 0; i < count; i++) {
            MenuItem childItem = subMenu.getItem(i);
            if (childItem.isVisible() && childItem.getIcon() != null) {
                preserveIconSpacing = true;
                break;
            }
        }
        subPopup.setForceShowIcon(preserveIconSpacing);
        if (subPopup.tryShow()) {
            if (this.mPresenterCallback != null) {
                this.mPresenterCallback.onOpenSubMenu(subMenu);
            }
            return true;
        }
    }
    return false;
}
 
Example 3
Project: boohee_v5.6   File: ActionMenuPresenter.java   View Source Code Vote up 6 votes
public ActionButtonSubmenu(Context context, SubMenuBuilder subMenu) {
    super(context, subMenu, null, false, R.attr.actionOverflowMenuStyle);
    this.mSubMenu = subMenu;
    if (!((MenuItemImpl) subMenu.getItem()).isActionButton()) {
        setAnchorView(ActionMenuPresenter.this.mOverflowButton == null ? (View) ActionMenuPresenter.this.mMenuView : ActionMenuPresenter.this.mOverflowButton);
    }
    setCallback(ActionMenuPresenter.this.mPopupPresenterCallback);
    boolean preserveIconSpacing = false;
    int count = subMenu.size();
    for (int i = 0; i < count; i++) {
        MenuItem childItem = subMenu.getItem(i);
        if (childItem.isVisible() && childItem.getIcon() != null) {
            preserveIconSpacing = true;
            break;
        }
    }
    setForceShowIcon(preserveIconSpacing);
}
 
Example 4
Project: easyfilemanager   File: FabSpeedDial.java   View Source Code Vote up 5 votes
private void addMenuItems() {
    ViewCompat.setAlpha(menuItemsLayout, 1f);
    for (int i = 0; i < navigationMenu.size(); i++) {
        MenuItem menuItem = navigationMenu.getItem(i);
        if (menuItem.isVisible()) {
            menuItemsLayout.addView(createFabMenuItem(menuItem));
        }
    }
    animateFabMenuItemsIn();
}
 
Example 5
Project: chromium-for-android-56-debug-video   File: AppMenuPropertiesDelegate.java   View Source Code Vote up 5 votes
private void disableEnableMenuItem(
        Menu menu, int id, boolean visible, boolean enabled, boolean managed) {
    for (int i = 0; i < menu.size(); ++i) {
        MenuItem item = menu.getItem(i);
        if (item.getItemId() == id && item.isVisible()) {
            item.setVisible(visible);
            item.setEnabled(enabled);
            if (managed) {
                item.setIcon(ManagedPreferencesUtils.getManagedByEnterpriseIconId());
            } else {
                item.setIcon(null);
            }
        }
    }
}
 
Example 6
Project: MaterialOCR   File: FabSpeedDial.java   View Source Code Vote up 5 votes
private void addMenuItems() {
    ViewCompat.setAlpha(menuItemsLayout, 1f);
    for (int i = 0; i < navigationMenu.size(); i++) {
        MenuItem menuItem = navigationMenu.getItem(i);
        if (menuItem.isVisible()) {
            menuItemsLayout.addView(createFabMenuItem(menuItem));
        }
    }
    animateFabMenuItemsIn();
}
 
Example 7
Project: FireFiles   File: FabSpeedDial.java   View Source Code Vote up 5 votes
private void addMenuItems() {
    ViewCompat.setAlpha(menuItemsLayout, 1f);
    for (int i = 0; i < navigationMenu.size(); i++) {
        MenuItem menuItem = navigationMenu.getItem(i);
        if (menuItem.isVisible()) {
            menuItemsLayout.addView(createFabMenuItem(menuItem));
        }
    }
    animateFabMenuItemsIn();
}
 
Example 8
Project: MaterialFabSpeedDial   File: FabSpeedDial.java   View Source Code Vote up 5 votes
private void refreshMenus() {
    menuContainer.removeAllViews();
    for (int i = 0; i < menu.size(); i++) {
        MenuItem menuItem = menu.getItem(i);
        if (menuItem.isVisible()) {
            View itemView = createItemView(i, menuItem);
            menuContainer.addView(itemView);
        }
    }
}
 
Example 9
Project: simple-share-android   File: FabSpeedDial.java   View Source Code Vote up 5 votes
private void addMenuItems() {
    ViewCompat.setAlpha(menuItemsLayout, 1f);
    for (int i = 0; i < navigationMenu.size(); i++) {
        MenuItem menuItem = navigationMenu.getItem(i);
        if (menuItem.isVisible()) {
            menuItemsLayout.addView(createFabMenuItem(menuItem));
        }
    }
    animateFabMenuItemsIn();
}
 
Example 10
Project: SimpleRssReader   File: MainActivity.java   View Source Code Vote up 5 votes
private void toggleMenuItemVisibility(final MenuItem item, final boolean visible) {
    if (visible) {
        if (!item.isVisible()) {
            item.setVisible(true);
        }
    } else if (item.isVisible()) {
        item.setVisible(false);
    }
}
 
Example 11
Project: revolution-irc   File: MainActivity.java   View Source Code Vote up 4 votes
@Override
public boolean onPrepareOptionsMenu(Menu menu) {
    boolean hasChanges = false;
    if (getCurrentFragment() instanceof ChatFragment) {
        ChatFragment fragment = ((ChatFragment) getCurrentFragment());
        ServerConnectionApi api = ((ServerConnectionApi) fragment.getConnectionInfo().getApiInstance());
        boolean connected = fragment.getConnectionInfo().isConnected();
        boolean wasConnected = !menu.findItem(R.id.action_reconnect).isVisible();
        if (connected != wasConnected) {
            if (connected) {
                menu.findItem(R.id.action_reconnect).setVisible(false);
                menu.findItem(R.id.action_close).setVisible(false);
                menu.findItem(R.id.action_disconnect).setVisible(true);
                menu.findItem(R.id.action_disconnect_and_close).setVisible(true);
            } else {
                menu.findItem(R.id.action_reconnect).setVisible(true);
                menu.findItem(R.id.action_close).setVisible(true);
                menu.findItem(R.id.action_disconnect).setVisible(false);
                menu.findItem(R.id.action_disconnect_and_close).setVisible(false);
            }
            hasChanges = true;
        }
        if (fragment.getSendMessageHelper().hasSendMessageTextSelection() !=
                menu.findItem(R.id.action_format).isVisible()) {
            menu.findItem(R.id.action_format).setVisible(fragment.getSendMessageHelper()
                    .hasSendMessageTextSelection());
            hasChanges = true;
        }
        MenuItem partItem = menu.findItem(R.id.action_part_channel);
        if (fragment.getCurrentChannel() == null) {
            if (partItem.isVisible())
                hasChanges = true;
            partItem.setVisible(false);
        } else if (fragment.getCurrentChannel().length() > 0 && !api.getServerConnectionData()
                .getSupportList().getSupportedChannelTypes().contains(fragment.getCurrentChannel().charAt(0))) {
            if (partItem.isVisible() || !partItem.getTitle().equals(getString(R.string.action_close_direct)))
                hasChanges = true;
            partItem.setVisible(true);
            partItem.setTitle(R.string.action_close_direct);
        } else {
            if (partItem.isVisible() || !partItem.getTitle().equals(getString(R.string.action_part_channel)))
                hasChanges = true;
            partItem.setVisible(true);
            partItem.setTitle(R.string.action_part_channel);
        }
    }
    return super.onPrepareOptionsMenu(menu) | hasChanges;
}
 
Example 12
Project: login   File: BottomSheetAdapterBuilder.java   View Source Code Vote up 4 votes
private List<BottomSheetItem> createAdapterItems(int dividerBackground, int titleTextColor,
                                                 int itemTextColor, int itemBackground,
                                                 int tintColor) {
    List<BottomSheetItem> items = new ArrayList<>();
    mTitles = 0;

    boolean addedSubMenu = false;

    for (int i = 0; i < mMenu.size(); i++) {
        MenuItem item = mMenu.getItem(i);

        if (item.isVisible()) {
            if (item.hasSubMenu()) {
                SubMenu subMenu = item.getSubMenu();

                if (i != 0 && addedSubMenu) {
                    if (mMode == BottomSheetBuilder.MODE_GRID) {
                        throw new IllegalArgumentException("MODE_GRID can't have submenus." +
                                " Use MODE_LIST instead");
                    }
                    items.add(new BottomSheetDivider(dividerBackground));
                }

                CharSequence title = item.getTitle();
                if (title != null && !title.equals("")) {
                    items.add(new BottomSheetHeader(title.toString(), titleTextColor));
                    mTitles++;
                }

                for (int j = 0; j < subMenu.size(); j++) {
                    MenuItem subItem = subMenu.getItem(j);
                    if (subItem.isVisible()) {
                        items.add(new BottomSheetMenuItem(subItem,itemTextColor, itemBackground, tintColor));
                        addedSubMenu = true;
                    }
                }
            } else {
                items.add(new BottomSheetMenuItem(item, itemTextColor, itemBackground, tintColor));
            }
        }
    }
    return items;
}
 
Example 13
Project: SimpleRssReader   File: MainActivity.java   View Source Code Vote up 4 votes
@Override
public boolean onPrepareOptionsMenu(final Menu menu) {
    final MenuItem itemUpdate = menu.findItem(R.id.action_update);
    final MenuItem itemSortEntries = menu.findItem(R.id.action_sort_entries);
    final MenuItem itemExportAsOPML = menu.findItem(R.id.action_opml_export);
    final MenuItem itemFilter = menu.findItem(R.id.action_filter_by_categories);
    final MenuItem itemSearch = menu.findItem(R.id.action_search);
    final MenuItem itemSettings = menu.findItem(R.id.action_settings);
    final MenuItem itemFilterSubs = menu.findItem(R.id.action_filter_subscriptions_by_category);

    final boolean isSearchViewNotExpanded = !isSearchViewExpanded();

    if (isNotInInitialSetup()) {
        if (getLoadCurrentFeedFragment().isAdded()) {
            toggleMenuItemVisibility(itemSearch, false);
            toggleMenuItemVisibility(itemSortEntries, false);
            toggleMenuItemVisibility(itemFilterSubs, false);
            toggleMenuItemVisibility(itemExportAsOPML, false);
        } else if (getCurrentFeedFragment().isAdded()) {
            toggleMenuItemVisibility(itemSortEntries, false);
            toggleMenuItemVisibility(itemFilterSubs, false);
            toggleMenuItemVisibility(itemExportAsOPML, false);

            if (isSearchViewNotExpanded) {
                toggleMenuItemVisibility(itemUpdate, true);
                toggleMenuItemVisibility(itemSearch, true);
            }

            if (CurrentFeed.isRSSFeed() && CurrentFeed.isCategoriesAvailable() &&
                    isSearchViewNotExpanded) {
                toggleMenuItemVisibility(itemFilter, true);
            }
        } else if (getFeedSubscriptionsFragment().isAdded()) {
            toggleMenuItemVisibility(itemUpdate, false);
            toggleMenuItemVisibility(itemSortEntries, false);
            toggleMenuItemVisibility(itemFilter, false);

            if (isSearchViewNotExpanded) {
                toggleMenuItemVisibility(itemFilterSubs, true);
                toggleMenuItemVisibility(itemExportAsOPML, true);
                toggleMenuItemVisibility(itemSearch, true);
            }
        } else if (getSavedEntriesFragment().isAdded()) {
            toggleMenuItemVisibility(itemUpdate, false);
            toggleMenuItemVisibility(itemFilter, false);
            toggleMenuItemVisibility(itemFilterSubs, false);
            toggleMenuItemVisibility(itemExportAsOPML, false);

            if (isSearchViewNotExpanded) {
                toggleMenuItemVisibility(itemSortEntries, true);
                toggleMenuItemVisibility(itemSearch, true);
            }

            final MenuItem itemSortOrderAsc =
                    menu.findItem(R.id.action_sort_order_ascending);
            final MenuItem itemSortOrderDesc =
                    menu.findItem(R.id.action_sort_order_descending);

            if (getSavedEntriesFragment().getSortOrder() == SORT_ORDER_DESCENDING) {
                itemSortOrderDesc.setEnabled(false);

                if (!itemSortOrderAsc.isVisible()) {
                    itemSortOrderAsc.setVisible(true);
                }
            } else {
                itemSortOrderAsc.setEnabled(false);

                if (!itemSortOrderDesc.isVisible()) {
                    itemSortOrderDesc.setVisible(true);
                }
            }
        }

        if (isSearchViewNotExpanded) {
            toggleMenuItemVisibility(itemSettings, true);
        }
    }

    return true;
}