Example usage for android.view MenuItem isVisible

List of usage examples for android.view MenuItem isVisible

Introduction

In this page you can find the example usage for android.view MenuItem isVisible.

Prototype

public boolean isVisible();

Source Link

Document

Return the visibility of the menu item.

Usage

From source file:org.mariotaku.twidere.util.ThemeUtils.java

public static void wrapToolbarMenuIcon(@Nullable ActionMenuView view, int itemColor, int popupItemColor,
        int... excludeGroups) {
    if (view == null)
        return;/* w  w  w .  j  a  v a 2  s .c  o m*/
    final Menu menu = view.getMenu();
    final int childCount = view.getChildCount();
    for (int i = 0, j = menu.size(), k = 0; i < j; i++) {
        final MenuItem item = menu.getItem(i);
        wrapMenuItemIcon(item, itemColor, excludeGroups);
        if (item.hasSubMenu()) {
            wrapMenuIcon(item.getSubMenu(), popupItemColor, popupItemColor, excludeGroups);
        }
        if (item.isVisible()) {
            k++;
        }
    }
}

From source file:org.mariotaku.twidere.util.ThemeUtils.java

public static void wrapMenuIcon(ActionMenuView view, int colorDark, int colorLight, int... excludeGroups) {
    final int itemBackgroundColor = ThemeUtils.getThemeBackgroundColor(view.getContext());
    final int popupItemBackgroundColor = ThemeUtils.getThemeBackgroundColor(view.getContext(),
            view.getPopupTheme());// ww  w.  ja va  2  s  .  c o  m
    final int itemColor = TwidereColorUtils.getContrastYIQ(itemBackgroundColor, colorDark, colorLight);
    final int popupItemColor = TwidereColorUtils.getContrastYIQ(popupItemBackgroundColor, colorDark,
            colorLight);
    final Menu menu = view.getMenu();
    final int childCount = view.getChildCount();
    for (int i = 0, j = menu.size(), k = 0; i < j; i++) {
        final MenuItem item = menu.getItem(i);
        wrapMenuItemIcon(item, itemColor, excludeGroups);
        if (item.hasSubMenu()) {
            wrapMenuIcon(item.getSubMenu(), popupItemColor, popupItemColor, excludeGroups);
        }
        if (item.isVisible()) {
            k++;
        }
    }
}

From source file:lewa.support.v7.internal.view.menu.MenuItemWrapperICS.java

MenuItemWrapperICS(android.view.MenuItem object, boolean emulateProviderVisibilityOverride) {
    super(object);
    mLastRequestVisible = object.isVisible();
    mEmulateProviderVisibilityOverride = emulateProviderVisibilityOverride;
}

From source file:com.btmura.android.reddit.app.CommentListController.java

private void prepareAuthorActionItem(Menu menu, ListView lv, int pos) {
    String author = getAuthor(pos);
    MenuItem item = menu.findItem(R.id.menu_author);
    item.setVisible(MenuHelper.isUserItemVisible(author) && isCheckedCount(lv, 1));
    if (item.isVisible()) {
        item.setTitle(MenuHelper.getUserTitle(context, author));
    }/*w  ww.  j a v  a  2  s .  c o  m*/
}

From source file:com.dodo.wbbshoutbox.codebot.MainActivity.java

@Override
public boolean onCreateOptionsMenu(Menu menu) {
    getMenuInflater().inflate(R.menu.main, menu);

    menucopy = menu;/*from   w ww.j  a  v  a  2s. c  om*/
    MenuItem item_login = menucopy.findItem(R.id.login);

    if (!UserData.readPref("cookies", this).equals("") && item_login.isVisible()) {
        updateMenu();
    }

    return true;
}

From source file:org.solovyev.android.widget.menu.CustomPopupMenuHelper.java

@Override
public boolean onSubMenuSelected(SubMenuBuilder subMenu) {
    if (subMenu.hasVisibleItems()) {
        CustomPopupMenuHelper subPopup = new CustomPopupMenuHelper(mContext, subMenu, mAnchorView, false,
                mPopupStyleAttr, mPopupStyleRes);
        subPopup.setGravity(mGravity);//  w w w.  j ava  2  s . c o  m
        subPopup.setCallback(mPresenterCallback);
        subPopup.setKeepOnSubMenu(mKeepOnSubMenu);

        boolean preserveIconSpacing = false;
        final 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 (mPresenterCallback != null) {
                mPresenterCallback.onOpenSubMenu(subMenu);
            }
            return true;
        }
    }
    return false;
}

From source file:com.nile.kmooc.view.custom.popup.menu.MenuPopupHelper.java

@Override
public boolean onSubMenuSelected(SubMenuBuilder subMenu) {
    if (subMenu.hasVisibleItems()) {
        MenuPopupHelper subPopup = new MenuPopupHelper(mContext, subMenu, mAnchorView);
        subPopup.setCallback(mPresenterCallback);

        boolean preserveIconSpacing = false;
        final 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;
            }/*from w ww.  j a  v a 2  s .  c o  m*/
        }
        subPopup.setForceShowIcon(preserveIconSpacing);

        if (subPopup.tryShow()) {
            if (mPresenterCallback != null) {
                mPresenterCallback.onOpenSubMenu(subMenu);
            }
            return true;
        }
    }
    return false;
}

From source file:io.github.yavski.fabspeeddial.FabSpeedDial.java

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));
        }//ww  w  .j a  v  a 2 s . co m
    }
    animateFabMenuItemsIn();
}

From source file:com.github.rubensousa.floatingtoolbar.FloatingToolbar.java

/**
 * Place the menu items with icons inside a horizontal LinearLayout
 *///  w ww .j  av  a  2 s.com
private void addMenuItems() {

    if (mMenu == null) {
        mMenu = new MenuBuilder(getContext());
        new SupportMenuInflater(getContext()).inflate(mMenuRes, mMenu);
    }

    LinearLayoutCompat.LayoutParams layoutParams = new LinearLayoutCompat.LayoutParams(
            LayoutParams.WRAP_CONTENT, LayoutParams.MATCH_PARENT, 1);

    setWeightSum(mMenu.size());

    for (int i = 0; i < mMenu.size(); i++) {
        MenuItem item = mMenu.getItem(i);
        if (item.isVisible()) {
            AppCompatImageButton imageButton = new AppCompatImageButton(getContext());
            //noinspection ResourceType
            imageButton.setId(item.getItemId() == Menu.NONE ? genViewId() : item.getItemId());
            imageButton.setBackgroundResource(mItemBackground);
            imageButton.setImageDrawable(item.getIcon());
            imageButton.setOnClickListener(this);
            imageButton.setOnLongClickListener(this);
            imageButton.setTag(item);
            mMenuLayout.addView(imageButton, layoutParams);
        }
    }
}

From source file:com.cachirulop.moneybox.activity.MovementDetailActivity.java

/**
 * Load the menu from the movement_detail.xml file.
 * /*from w  ww .  j  a v  a 2  s . c  om*/
 * Activates and deactivates the put and drop menu buttons depending of the
 * movement.
 * 
 * @param menu
 *            Menu to be inflated with the menu inflater.
 */
@Override
public boolean onCreateOptionsMenu(Menu menu) {
    // Inflate the menu; this adds items to the action bar if it is present.
    getMenuInflater().inflate(R.menu.movement_detail, menu);

    MenuItem item;

    item = menu.findItem(R.id.action_get_from_moneybox);
    item.setVisible(MovementsManager.canGetMovement(_movement));
    item.setEnabled(item.isVisible());

    item = menu.findItem(R.id.action_drop_to_moneybox);
    item.setVisible(MovementsManager.canDropMovement(_movement));
    item.setEnabled(item.isVisible());

    item = menu.findItem(R.id.action_delete_movement);
    item.setVisible(MovementsManager.canDeleteMovement(_movement));
    item.setEnabled(item.isVisible());

    return true;
}