Example usage for android.view Menu NONE

List of usage examples for android.view Menu NONE

Introduction

In this page you can find the example usage for android.view Menu NONE.

Prototype

int NONE

To view the source code for android.view Menu NONE.

Click Source Link

Document

Value to use for group and item identifier integers when you don't care about them.

Usage

From source file:com.github.chenxiaolong.dualbootpatcher.switcher.RomDetailActivity.java

@Override
public boolean onCreateOptionsMenu(Menu menu) {
    menu.add(0, MENU_EDIT_NAME, Menu.NONE, R.string.rom_menu_edit_name);
    menu.add(0, MENU_CHANGE_IMAGE, Menu.NONE, R.string.rom_menu_change_image);
    menu.add(0, MENU_RESET_IMAGE, Menu.NONE, R.string.rom_menu_reset_image);
    return true;/*from www .j  a v a2s  . co  m*/
}

From source file:com.grarak.kerneladiutor.fragments.RecyclerViewFragment.java

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

    if (!hideBanner())
        return;//from   w  w w .j a  v a  2s  .  com

    if (showViewPager()) {
        menu.add(0, 0, Menu.NONE, R.string.options)
                .setIcon(ContextCompat.getDrawable(getActivity(), R.drawable.ic_launcher_preview))
                .setShowAsActionFlags(MenuItem.SHOW_AS_ACTION_IF_ROOM);
    }
    if (showTopFab()) {
        menu.add(0, 1, Menu.NONE, R.string.more).setIcon(getTopFabDrawable())
                .setShowAsActionFlags(MenuItem.SHOW_AS_ACTION_IF_ROOM);
    } else if (showBottomFab()) {
        menu.add(0, 1, Menu.NONE, R.string.more).setIcon(getBottomFabDrawable())
                .setShowAsActionFlags(MenuItem.SHOW_AS_ACTION_IF_ROOM);
    }
}

From source file:com.ruesga.rview.MainActivity.java

private void updateAccountsDrawerInfo() {
    // Remove all accounts and re-add them
    final DrawerNavigationMenu menu = (DrawerNavigationMenu) mBinding.drawerNavigationView.getMenu();
    int otherAccountGroupIndex = menu.findGroupIndex(R.id.category_other_accounts);
    MenuItem group = menu.getItem(otherAccountGroupIndex);
    SubMenu otherAccountsSubMenu = group.getSubMenu();
    int count = otherAccountsSubMenu.size() - 1;
    for (int i = count; i > 0; i--) {
        ((DrawerNavigationSubMenu) otherAccountsSubMenu).removeItemAt(i);
    }/*  ww w.  j ava2s . c o m*/
    int i = 0;
    for (Account account : mAccounts) {
        // Current account
        if (mAccount.isSameAs(account)) {
            i++;
            continue;
        }

        int id = OTHER_ACCOUNTS_GROUP_BASE_ID + i;
        String title = account.getAccountDisplayName() + DrawerNavigationView.SEPARATOR
                + account.getRepositoryDisplayName() + DrawerNavigationView.SEPARATOR + "ic_delete"
                + DrawerNavigationView.SEPARATOR + "false";
        MenuItem item = otherAccountsSubMenu.add(group.getGroupId(), id, Menu.NONE, title);

        PicassoHelper.bindAvatar(this, PicassoHelper.getPicassoClient(this), account, account.mAccount, item,
                PicassoHelper.getDefaultAvatar(this, R.color.primaryDarkForeground));
        i++;
    }

    if (mAccount != null) {
        updateAccountStatus();
    }
}

From source file:com.teitsmch.hearthmaker.MainActivity.java

public void setNavigationMenuItem(int menuItemId, String menuItemName) {
    mDrawerList.getMenu().findItem(R.id.navigation_deck_item).getSubMenu().add(R.id.navigation_deck_group,
            menuItemId, Menu.NONE, menuItemName);
}

From source file:org.spinsuite.view.V_Process.java

/**
 * Show Print Formats//from  w ww  .  j a v  a 2s  . c o  m
 * @author <a href="mailto:yamelsenih@gmail.com">Yamel Senih</a> 31/03/2014, 11:57:26
 * @return void
 */
private void showPrintFormat() {
    View menuItemView = findViewById(R.id.action_print_format);
    pPrintFormat = new PopupMenu(this, menuItemView);
    for (KeyNamePair pFormat : m_PrintFormats) {
        pPrintFormat.getMenu().add(Menu.NONE, pFormat.getKey(), Menu.NONE, pFormat.getName());
    }
    //   Listener
    pPrintFormat.setOnMenuItemClickListener(new PopupMenu.OnMenuItemClickListener() {

        @Override
        public boolean onMenuItemClick(MenuItem item) {
            int m_AD_PrintFormatItem_ID = item.getItemId();
            if (isLoaded) {
                showReport(m_AD_PrintFormatItem_ID);
            }
            return false;
        }
    });
    //   Show
    pPrintFormat.show();
}

From source file:org.alfresco.mobile.android.application.fragments.browser.ChildrenBrowserFragment.java

public void getMenu(Menu menu) {
    if (parentFolder == null) {
        return;/* w  w  w.  j  a  va  2 s.  c o  m*/
    }

    if (getActivity() instanceof MainActivity) {
        getMenu(alfSession, menu, parentFolder);

        if (hasDocument()) {
            displayMenuItem = menu.add(Menu.NONE, MenuActionItem.MENU_DISPLAY_GALLERY,
                    Menu.FIRST + MenuActionItem.MENU_DISPLAY_GALLERY, R.string.display_gallery);
            displayMenuItem.setShowAsAction(MenuItem.SHOW_AS_ACTION_NEVER);
        }
    } else if (getActivity() instanceof PublicDispatcherActivity) {
        Permissions permission = alfSession.getServiceRegistry().getDocumentFolderService()
                .getPermissions(parentFolder);

        if (permission.canAddChildren()) {
            MenuItem mi = menu.add(Menu.NONE, MenuActionItem.MENU_CREATE_FOLDER,
                    Menu.FIRST + MenuActionItem.MENU_CREATE_FOLDER, R.string.folder_create);
            mi.setIcon(R.drawable.ic_add_folder);
            mi.setShowAsAction(MenuItem.SHOW_AS_ACTION_IF_ROOM);
        }
    }

    // Uncomment for enabling view switcher
    /*
     * displayMenuItem = menu.add(Menu.NONE,
     * MenuActionItem.MENU_DISPLAY_ITEMS, Menu.FIRST +
     * MenuActionItem.MENU_DISPLAY_ITEMS, R.string.display_views); switch
     * (displayMode) { case DISPLAY_LIST:
     * displayMenuItem.setIcon(R.drawable.ic_action_list); break; case
     * DISPLAY_LIST_LARGE:
     * displayMenuItem.setIcon(R.drawable.ic_action_tiles_small); break;
     * case DISPLAY_GRID:
     * displayMenuItem.setIcon(R.drawable.ic_action_list_2); break; default:
     * break; }
     * displayMenuItem.setShowAsAction(MenuItem.SHOW_AS_ACTION_IF_ROOM);
     */
}

From source file:org.getlantern.firetweet.util.Utils.java

public static void addIntentToMenuForExtension(final Context context, final Menu menu, final int groupId,
        final String action, final String parelableKey, final String parelableJSONKey,
        final FiretweetParcelable parcelable) {
    if (context == null || menu == null || action == null || parelableKey == null || parcelable == null)
        return;//from   w w w. j a v  a  2  s .  co m
    final PackageManager pm = context.getPackageManager();
    final Resources res = context.getResources();
    final float density = res.getDisplayMetrics().density;
    final int padding = Math.round(density * 4);
    final Intent queryIntent = new Intent(action);
    queryIntent.setExtrasClassLoader(context.getClassLoader());
    final List<ResolveInfo> activities = pm.queryIntentActivities(queryIntent, PackageManager.GET_META_DATA);
    for (final ResolveInfo info : activities) {
        final Intent intent = new Intent(queryIntent);
        if (isExtensionUseJSON(info)) {
            intent.putExtra(parelableJSONKey, JSONSerializer.toJSONObjectString(parcelable));
        } else {
            intent.putExtra(parelableKey, parcelable);
        }
        intent.setClassName(info.activityInfo.packageName, info.activityInfo.name);
        final MenuItem item = menu.add(groupId, Menu.NONE, Menu.NONE, info.loadLabel(pm));
        item.setIntent(intent);
        final Drawable metaDataDrawable = getMetadataDrawable(pm, info.activityInfo,
                METADATA_KEY_EXTENSION_ICON);
        final int actionIconColor = ThemeUtils.getThemeForegroundColor(context);
        if (metaDataDrawable != null) {
            metaDataDrawable.mutate();
            metaDataDrawable.setColorFilter(actionIconColor, Mode.SRC_ATOP);
            item.setIcon(metaDataDrawable);
        } else {
            final Drawable icon = info.loadIcon(pm);
            final int iw = icon.getIntrinsicWidth(), ih = icon.getIntrinsicHeight();
            if (iw > 0 && ih > 0) {
                final Drawable iconWithPadding = new PaddingDrawable(icon, padding);
                iconWithPadding.setBounds(0, 0, iw, ih);
                item.setIcon(iconWithPadding);
            } else {
                item.setIcon(icon);
            }
        }

    }
}

From source file:com.hichinaschool.flashcards.anki.CardEditor.java

@Override
public boolean onCreateOptionsMenu(Menu menu) {
    MenuItem item;//from   w ww  . ja v a  2 s.com
    Resources res = getResources();
    // Lookup.initialize(this, mDeck.getDeckPath());
    // item = menu.add(Menu.NONE, MENU_LOOKUP, Menu.NONE,
    // Lookup.getSearchStringTitle());
    // item.setIcon(R.drawable.ic_menu_search);
    // item.setEnabled(Lookup.isAvailable());
    // item = menu.add(Menu.NONE, MENU_RESET, Menu.NONE,
    // res.getString(R.string.card_editor_reset));
    // item.setIcon(R.drawable.ic_menu_revert);
    if (!mAddNote) {
        item = menu.add(Menu.NONE, MENU_ADD_CARD, Menu.NONE, res.getString(R.string.card_editor_add_card));
        item.setIcon(R.drawable.ic_menu_add);
    }
    item = menu.add(Menu.NONE, MENU_COPY_CARD, Menu.NONE, res.getString(R.string.card_editor_copy_card));
    item.setIcon(R.drawable.ic_menu_upload);
    if (!mAddNote) {
        item = menu.add(Menu.NONE, MENU_RESET_CARD_PROGRESS, Menu.NONE,
                res.getString(R.string.card_editor_reset_card));
        item.setIcon(R.drawable.ic_menu_delete);
    }
    if (mCaller != CALLER_CARDEDITOR_INTENT_ADD) {
        mIntentInformation = MetaDB.getIntentInformation(this);
        item = menu.add(Menu.NONE, MENU_SAVED_INTENT, Menu.NONE,
                res.getString(R.string.intent_add_saved_information));
        item.setIcon(R.drawable.ic_menu_archive);
    }
    return true;
}

From source file:edu.cmu.cylab.starslinger.view.MessagesFragment.java

@Override
public void onCreateContextMenu(ContextMenu menu, View v, ContextMenuInfo menuInfo) {
    super.onCreateContextMenu(menu, v, menuInfo);

    AdapterContextMenuInfo info = (AdapterContextMenuInfo) menuInfo;
    if (v.equals(mListViewThreads)) {
        RecipientRow recip = mThreadList.get(info.position).getRecipient();
        String delThreadStr = String.format(getString(R.string.menu_deleteThread),
                ThreadsAdapter.getBestIdentityName(getActivity(), mThreadList.get(info.position), recip));
        menu.add(Menu.NONE, R.id.item_delete_thread, Menu.NONE, delThreadStr);
        if (recip != null && recip.getRowId() > -1
                && recip.getSource() != RecipientDbAdapter.RECIP_SOURCE_INVITED) {
            if (!recip.isValidContactLink()) {
                menu.add(Menu.NONE, R.id.item_link_contact_add, Menu.NONE, R.string.menu_link_contact_add);
            } else {
                menu.add(Menu.NONE, R.id.item_link_contact_change, Menu.NONE,
                        R.string.menu_link_contact_change);
            }//from w  ww. j a  v a  2s  .  c om

            if (recip.isValidContactLink()) {
                menu.add(Menu.NONE, R.id.item_edit_contact, Menu.NONE, R.string.menu_EditContact);
            }
        }
        menu.add(Menu.NONE, R.id.item_thread_details, Menu.NONE, R.string.menu_Details);
    } else if (v.equals(mListViewMsgs)) {
        MenuInflater inflater = getActivity().getMenuInflater();
        inflater.inflate(R.layout.messagecontext, menu);

        final String text = mMessageList.get(info.position).getText();
        final String file = mMessageList.get(info.position).getFileName();
        if (!TextUtils.isEmpty(text)) {
            menu.add(Menu.NONE, R.id.item_message_copytext, Menu.NONE, R.string.menu_messageCopyText);
        }
        if (!TextUtils.isEmpty(text) || !TextUtils.isEmpty(file)) {
            menu.add(Menu.NONE, R.id.item_message_forward, Menu.NONE, R.string.menu_messageForward);
        }
        menu.add(Menu.NONE, R.id.item_message_details, Menu.NONE, R.string.menu_Details);

        if (SafeSlingerConfig.isDebug()) {
            menu.add(Menu.NONE, R.id.item_debug_transcript, Menu.NONE, R.string.menu_debugTranscript);
        }
    }
}

From source file:org.alfresco.mobile.android.application.fragments.browser.ChildrenBrowserFragment.java

public static void getMenu(AlfrescoSession session, Menu menu, Folder parentFolder, boolean actionMode) {
    MenuItem mi;/*from   w w  w.  j a  v  a2  s  . c o m*/

    if (parentFolder == null) {
        return;
    }
    Permissions permission = null;
    try {
        permission = session.getServiceRegistry().getDocumentFolderService().getPermissions(parentFolder);
    } catch (Exception e) {
        return;
    }

    if (!actionMode) {
        mi = menu.add(Menu.NONE, MenuActionItem.MENU_SEARCH_FOLDER,
                Menu.FIRST + MenuActionItem.MENU_SEARCH_FOLDER, R.string.search);
        mi.setIcon(R.drawable.ic_search);
        mi.setShowAsAction(MenuItem.SHOW_AS_ACTION_IF_ROOM);
    }

    if (!actionMode && permission.canAddChildren()) {
        mi = menu.add(Menu.NONE, MenuActionItem.MENU_CREATE_FOLDER,
                Menu.FIRST + MenuActionItem.MENU_CREATE_FOLDER, R.string.folder_create);
        mi.setIcon(R.drawable.ic_add_folder);
        mi.setShowAsAction(MenuItem.SHOW_AS_ACTION_IF_ROOM);

        SubMenu createMenu = menu.addSubMenu(Menu.NONE, MenuActionItem.MENU_DEVICE_CAPTURE,
                Menu.FIRST + MenuActionItem.MENU_DEVICE_CAPTURE, R.string.add_menu);
        createMenu.setIcon(android.R.drawable.ic_menu_add);
        createMenu.getItem().setShowAsAction(MenuItem.SHOW_AS_ACTION_ALWAYS);

        createMenu.add(Menu.NONE, MenuActionItem.MENU_UPLOAD, Menu.FIRST + MenuActionItem.MENU_UPLOAD,
                R.string.upload_title);

        createMenu.add(Menu.NONE, MenuActionItem.MENU_CREATE_DOCUMENT,
                Menu.FIRST + MenuActionItem.MENU_CREATE_DOCUMENT, R.string.create_document);

        createMenu.add(Menu.NONE, MenuActionItem.MENU_DEVICE_CAPTURE_CAMERA_PHOTO,
                Menu.FIRST + MenuActionItem.MENU_DEVICE_CAPTURE_CAMERA_PHOTO, R.string.take_photo);

        if (AndroidVersion.isICSOrAbove()) {
            createMenu.add(Menu.NONE, MenuActionItem.MENU_DEVICE_CAPTURE_CAMERA_VIDEO,
                    Menu.FIRST + MenuActionItem.MENU_DEVICE_CAPTURE_CAMERA_VIDEO, R.string.make_video);
        }

        createMenu.add(Menu.NONE, MenuActionItem.MENU_DEVICE_CAPTURE_MIC_AUDIO,
                Menu.FIRST + MenuActionItem.MENU_DEVICE_CAPTURE_MIC_AUDIO, R.string.record_audio);

    }

    if (actionMode) {
        mi = menu.add(Menu.NONE, MenuActionItem.MENU_DETAILS, Menu.FIRST + MenuActionItem.MENU_DETAILS,
                R.string.action_view_properties);
        mi.setIcon(R.drawable.ic_details);
        mi.setShowAsAction(MenuItem.SHOW_AS_ACTION_IF_ROOM);
    }

    if (actionMode && permission.canEdit()) {
        mi = menu.add(Menu.NONE, MenuActionItem.MENU_EDIT, Menu.FIRST + MenuActionItem.MENU_EDIT,
                R.string.edit);
        mi.setIcon(R.drawable.ic_edit);
        mi.setShowAsAction(MenuItem.SHOW_AS_ACTION_IF_ROOM);
    }

    if (actionMode && permission.canDelete()) {
        mi = menu.add(Menu.NONE, MenuActionItem.MENU_DELETE, Menu.FIRST + MenuActionItem.MENU_DELETE,
                R.string.delete);
        mi.setIcon(R.drawable.ic_delete);
        mi.setShowAsAction(MenuItem.SHOW_AS_ACTION_IF_ROOM);
    }

    if (!actionMode) {
        mi = menu.add(Menu.NONE, MenuActionItem.MENU_REFRESH, Menu.FIRST + MenuActionItem.MENU_REFRESH,
                R.string.refresh);
        mi.setIcon(R.drawable.ic_refresh);
        mi.setShowAsAction(MenuItem.SHOW_AS_ACTION_IF_ROOM);
    }
}