Example usage for android.view MenuItem setVisible

List of usage examples for android.view MenuItem setVisible

Introduction

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

Prototype

public MenuItem setVisible(boolean visible);

Source Link

Document

Sets the visibility of the menu item.

Usage

From source file:com.joeyturczak.jtscanner.ui.FileListFragment.java

@Override
public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
    super.onCreateOptionsMenu(menu, inflater);
    MenuItem menuItem = menu.findItem(R.id.action_save_spreadsheet);
    menuItem.setVisible(true);
    Utility.tintMenuIcon(getContext(), menuItem, R.color.white);
}

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

private void prepareAuthorActionItem(Menu menu, int checkedCount, int position) {
    String author = adapter.getAuthor(position);
    boolean show = checkedCount == 1 && MenuHelper.isUserItemVisible(author);
    MenuItem item = menu.findItem(R.id.menu_author);
    item.setVisible(show);
    if (item.isVisible()) {
        item.setTitle(MenuHelper.getUserTitle(context, author));
    }/*from  w  w w.j a  va2s.c  o m*/
}

From source file:com.justplay1.shoppist.features.goods.GoodsActivity.java

@Override
public boolean onPrepareActionMode(ActionMode mode, Menu menu) {
    super.onPrepareActionMode(mode, menu);
    MenuItem edit = menu.findItem(R.id.action_edit);
    if (edit != null) {
        edit.setVisible(fragment.isEditButtonEnable());
    }//  w w  w .j  av  a2s  . c  o  m

    MenuItem checkAll = menu.findItem(R.id.menu_check_all);
    checkAll.setEnabled(fragment.isCheckAllButtonEnable());
    return true;
}

From source file:com.vuze.android.remote.activity.TorrentViewActivity.java

public static void prepareGlobalMenu(Menu menu, SessionInfo sessionInfo) {
    SessionSettings sessionSettings = sessionInfo == null ? null : sessionInfo.getSessionSettings();

    boolean isLocalHost = sessionInfo != null && sessionInfo.getRemoteProfile().isLocalHost();
    boolean isOnline = VuzeRemoteApp.getNetworkState().isOnline();

    MenuItem menuSessionSettings = menu.findItem(R.id.action_settings);
    if (menuSessionSettings != null) {
        menuSessionSettings.setEnabled(sessionSettings != null);
    }/*from  w  w  w.j a va 2s.  c  o m*/

    MenuItem menuRefresh = menu.findItem(R.id.action_refresh);
    if (menuRefresh != null) {
        boolean refreshVisible = TorrentUtils.isAllowRefresh(sessionInfo);
        menuRefresh.setVisible(refreshVisible);
        menuRefresh.setEnabled(sessionInfo == null ? false : !sessionInfo.isRefreshingTorrentList());
    }

    MenuItem menuSearch = menu.findItem(R.id.action_search);
    if (menuSearch != null) {
        if (AndroidUtils.isTV()) {
            menuSearch.setVisible(false);
        } else {
            menuSearch.setEnabled(isOnline);
        }
    }

    MenuItem menuStartAll = menu.findItem(R.id.action_start_all);
    if (menuStartAll != null) {
        menuStartAll.setEnabled(isOnline || isLocalHost);
    }

    MenuItem menuStopAll = menu.findItem(R.id.action_stop_all);
    if (menuStopAll != null) {
        menuStopAll.setEnabled(isOnline || isLocalHost);
    }

    MenuItem itemSocial = menu.findItem(R.id.action_social);
    if (itemSocial != null) {

        MenuItem menuVote = menu.findItem(R.id.action_vote);
        if (menuVote != null) {
            menuVote.setVisible(!AndroidUtils.isTV());
        }

        MenuItem menuForum = menu.findItem(R.id.action_forum);
        if (menuForum != null) {
            menuForum.setVisible(!AndroidUtils.isTV());
        }
    }

    MenuItem menuShutdownCore = menu.findItem(R.id.action_shutdown);
    if (menuShutdownCore != null) {
        boolean visible = sessionInfo != null && sessionInfo.getRemoteProfile() != null
                && sessionInfo.getRemoteProfile().getRemoteType() == RemoteProfile.TYPE_CORE;
        menuShutdownCore.setVisible(visible);
    }
}

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

private void prepareAboutItem(Menu menu, ListView lv, boolean visible) {
    MenuItem item = menu.findItem(R.id.menu_subreddit);
    item.setVisible(visible);
    if (visible) {
        item.setTitle(ctx.getString(R.string.menu_subreddit, getFirstCheckedSubreddit(lv)));
    }//w  w  w .j  ava2s  . c om
}

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

private void prepareAddItem(Menu menu) {
    AccountResult result = accountResultHolder.getAccountResult();
    MenuItem item = menu.findItem(R.id.menu_add_subreddit);
    item.setVisible(result != null && result.accountNames.length > 1);
}

From source file:com.luorrak.ouroboros.gallery.GalleryFragment.java

@Override
public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
    MenuItem saveAllImagesButton = menu.findItem(R.id.action_save_all_images);
    saveAllImagesButton.setVisible(true);
    super.onCreateOptionsMenu(menu, inflater);
}

From source file:de.schildbach.wallet.ui.AbstractWalletActivity.java

@Override
public boolean onCreateOptionsMenu(final Menu menu) {
    MenuItem walletLockMenuItem = menu.findItem(R.id.wallet_options_lock);
    if (walletLockMenuItem != null) {
        walletLockMenuItem
                .setVisible(WalletLock.getInstance().isWalletLocked(getWalletApplication().getWallet()));
    }//  w  w  w  .j  a  va 2 s.  c  o  m
    return super.onCreateOptionsMenu(menu);
}

From source file:lrstudios.util.android.ui.BetterFragmentActivity.java

protected boolean setOptionItemVisible(int itemMenuId, boolean visible) {
    if (_optionsMenu == null)
        return false;

    MenuItem item = _optionsMenu.findItem(itemMenuId);
    if (item == null)
        return false;

    item.setVisible(visible);
    return true;/*ww w .ja v a 2  s .c o m*/
}

From source file:ch.berta.fabio.popularmovies.presentation.ui.fragments.MovieDetailsBaseFragment.java

@Override
public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
    super.onCreateOptionsMenu(menu, inflater);

    inflater.inflate(R.menu.menu_movie_details, menu);
    MenuItem shareItem = menu.findItem(R.id.menu_details_action_share);
    shareItem.setVisible(mViewModel.hasMovieVideos());
}