Example usage for android.view Menu FIRST

List of usage examples for android.view Menu FIRST

Introduction

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

Prototype

int FIRST

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

Click Source Link

Document

First value for group and item identifier integers.

Usage

From source file:ca.cs.ualberta.localpost.view.FreshestTabView.java

@Override
public boolean onContextItemSelected(MenuItem item) {
    ConnectivityCheck conn = new ConnectivityCheck(getActivity());

    // Get item list index
    ElasticSearchOperations es = new ElasticSearchOperations();
    AdapterContextMenuInfo info = (AdapterContextMenuInfo) item.getMenuInfo();
    int index = (int) info.id;
    switch (item.getItemId()) {

    case Menu.FIRST://UpRad
        if (conn.isConnectingToInternet()) {
            Toast.makeText(getActivity(), "UpRad", Toast.LENGTH_SHORT).show();
            model.get(index).incRadish();
            es.execute(1, model.get(index).getPostId(), model.get(index), null);
            return true;
        } else {/* w ww.  j  a va2  s .c  o m*/
            Toast.makeText(getActivity(), "You require connectivity to Uprad", Toast.LENGTH_SHORT).show();
            return true;
        }
    case Menu.FIRST + 1://Down rad
        if (conn.isConnectingToInternet()) {
            Toast.makeText(getActivity(), "DownRad", Toast.LENGTH_SHORT).show();
            model.get(index).decRadish();
            es.execute(1, model.get(index).getPostId(), model.get(index), null);
            return true;
        } else {
            Toast.makeText(getActivity(), "You require connectivity to Downrad", Toast.LENGTH_SHORT).show();
            return true;
        }
    case Menu.FIRST + 2://Favorites
        Serialize.SaveComment(model.get(index), getActivity(), "favourite");
        Toast.makeText(getActivity(), "Comment has been Favorited", Toast.LENGTH_SHORT).show();
        Serialize.update(model.get(index), getActivity(), "favoritecomment.json");
        return true;
    }
    return super.onContextItemSelected(item);
}

From source file:org.alfresco.mobile.android.application.extension.samsung.pen.SNoteEditorActionMode.java

private void getMenu(Menu menu) {
    MenuItem mi;/*w  w  w. j  ava 2  s. co m*/
    menu.clear();

    mi = menu.add(Menu.NONE, SNoteMenuActionItem.CONTEXT_MENU_DELETE_ID,
            Menu.FIRST + SNoteMenuActionItem.MENU_EDITOR_SETTINGS, R.string.editor_tools_settings);
    mi.setIcon(R.drawable.ic_delete);
    mi.setShowAsAction(MenuItem.SHOW_AS_ACTION_IF_ROOM);

    // GROUP MENU
    if (selectedSpenObjects.size() > 1) {
        SubMenu groupSubMenu = menu.addSubMenu(Menu.NONE, SNoteMenuActionItem.MENU_EDITOR_TOOLS, Menu.FIRST,
                R.string.editor_group_menu);
        groupSubMenu.setIcon(R.drawable.ic_group);
        groupSubMenu.getItem().setShowAsAction(MenuItem.SHOW_AS_ACTION_ALWAYS);

        mi = groupSubMenu.add(Menu.NONE, SNoteMenuActionItem.CONTEXT_MENU_GROUP_ID,
                Menu.FIRST + SNoteMenuActionItem.CONTEXT_MENU_GROUP_ID, R.string.editor_group);

        mi = groupSubMenu.add(Menu.NONE, SNoteMenuActionItem.CONTEXT_MENU_UNGROUP_ID,
                Menu.FIRST + SNoteMenuActionItem.CONTEXT_MENU_UNGROUP_ID, R.string.editor_ungroup);

        mi.setEnabled(false);
        for (SpenObjectBase obj : selectedSpenObjects) {
            if (obj.getType() == SpenObjectBase.TYPE_CONTAINER) {
                mi.setEnabled(true);
                break;
            }
        }
    }

    // UP MENU
    SubMenu upMenu = menu.addSubMenu(Menu.NONE, SNoteMenuActionItem.MENU_EDITOR_TOOLS, Menu.FIRST,
            R.string.editor_front_menu);
    upMenu.setIcon(R.drawable.ic_move_up);
    upMenu.getItem().setShowAsAction(MenuItem.SHOW_AS_ACTION_ALWAYS);

    mi = upMenu.add(Menu.NONE, SNoteMenuActionItem.CONTEXT_MENU_MOVE_TO_FORWARD_ID,
            Menu.FIRST + SNoteMenuActionItem.CONTEXT_MENU_MOVE_TO_FORWARD_ID, R.string.editor_forward);

    mi = upMenu.add(Menu.NONE, SNoteMenuActionItem.CONTEXT_MENU_MOVE_TO_TOP_ID,
            Menu.FIRST + SNoteMenuActionItem.CONTEXT_MENU_MOVE_TO_TOP_ID, R.string.editor_front);

    // DOWN MENU
    SubMenu downMenu = menu.addSubMenu(Menu.NONE, SNoteMenuActionItem.MENU_EDITOR_TOOLS, Menu.FIRST,
            R.string.editor_back_menu);
    downMenu.setIcon(R.drawable.ic_move_down);
    downMenu.getItem().setShowAsAction(MenuItem.SHOW_AS_ACTION_ALWAYS);

    mi = downMenu.add(Menu.NONE, SNoteMenuActionItem.CONTEXT_MENU_MOVE_TO_BACKWARD_ID,
            Menu.FIRST + SNoteMenuActionItem.CONTEXT_MENU_MOVE_TO_BACKWARD_ID, R.string.editor_backward);

    mi = downMenu.add(Menu.NONE, SNoteMenuActionItem.CONTEXT_MENU_MOVE_TO_BOTTOM_ID,
            Menu.FIRST + SNoteMenuActionItem.CONTEXT_MENU_MOVE_TO_BOTTOM_ID, R.string.editor_back);
}

From source file:org.medankulinar.MixListView.java

@Override
public boolean onCreateOptionsMenu(Menu menu) {
    int base = Menu.FIRST;

    /*define menu items*/
    MenuItem item1 = menu.add(base, base, base, getString(R.string.menu_item_3));
    MenuItem item2 = menu.add(base, base + 1, base + 1, getString(R.string.map_menu_cam_mode));
    /*assign icons to the menu items*/
    item1.setIcon(android.R.drawable.ic_menu_mapmode);
    item2.setIcon(android.R.drawable.ic_menu_camera);

    return true;//from w w w  . j a va  2  s  .  c o  m
}

From source file:org.alfresco.mobile.android.application.fragments.person.PersonProfileFragment.java

public static void getMenu(Menu menu) {
    MenuItem mi = menu.add(Menu.NONE, MenuActionItem.MENU_PROFILE, Menu.FIRST + MenuActionItem.MENU_PROFILE,
            R.string.my_profile);/*from w w  w. ja  va 2 s  .co m*/
    mi.setIcon(R.drawable.ic_avatar);
    mi.setShowAsAction(MenuItem.SHOW_AS_ACTION_IF_ROOM);
}

From source file:org.alfresco.mobile.android.application.fragments.actions.NodeActions.java

protected void getMenu(FragmentActivity activity, Menu menu) {
    MenuItem mi;//from  ww w  .  java2  s . c  om
    SubMenu createMenu;

    if (selectedFolder.isEmpty()) {
        mi = menu.add(Menu.NONE, R.id.menu_action_download_all, Menu.FIRST, R.string.download);
        mi.setIcon(R.drawable.ic_download_light);
        mi.setShowAsAction(MenuItem.SHOW_AS_ACTION_IF_ROOM);
        removeActionIfNecessary(menu, mi.getItemId(), ConfigurableActionHelper.ACTION_NODE_DOWNLOAD);

        if (!(SessionUtils.getSession(activity) instanceof CloudSession)) {
            mi = menu.add(Menu.NONE, R.id.menu_workflow_review_attachments, Menu.FIRST + 500,
                    R.string.process_start_review);
            mi.setIcon(R.drawable.ic_start_review);
            mi.setShowAsAction(MenuItem.SHOW_AS_ACTION_IF_ROOM);
            removeActionIfNecessary(menu, mi.getItemId(), ConfigurableActionHelper.ACTION_NODE_REVIEW);
        }
    }

    // SYNC
    if (SyncContentManager.getInstance(getActivity()).hasActivateSync(getAccount())
            && !SyncContentManager.getInstance(getActivity()).isSynced(getAccount(), parentFolder)) {
        createMenu = menu.addSubMenu(Menu.NONE, R.id.menu_action_sync_group, Menu.FIRST, R.string.sync);
        createMenu.setIcon(R.drawable.ic_sync_light);
        createMenu.getItem().setShowAsAction(MenuItem.SHOW_AS_ACTION_ALWAYS);
        removeActionIfNecessary(menu, createMenu.getItem().getItemId(),
                ConfigurableActionHelper.ACTION_NODE_SYNC);

        createMenu.add(Menu.NONE, R.id.menu_action_sync_group_sync, Menu.FIRST + 1, R.string.sync);
        createMenu.add(Menu.NONE, R.id.menu_action_sync_group_unsync, Menu.FIRST + 2, R.string.unsync);
    }

    // FAVORITES
    createMenu = menu.addSubMenu(Menu.NONE, R.id.menu_action_favorite_group, Menu.FIRST + 135,
            R.string.favorite);
    createMenu.setIcon(R.drawable.ic_favorite_light);
    createMenu.getItem().setShowAsAction(MenuItem.SHOW_AS_ACTION_ALWAYS);
    removeActionIfNecessary(menu, createMenu.getItem().getItemId(),
            ConfigurableActionHelper.ACTION_NODE_FAVORITE);

    createMenu.add(Menu.NONE, R.id.menu_action_favorite_group_favorite, Menu.FIRST + 1, R.string.favorite);
    createMenu.add(Menu.NONE, R.id.menu_action_favorite_group_unfavorite, Menu.FIRST + 2, R.string.unfavorite);

    // LIKE
    AlfrescoSession alfSession = SessionUtils.getSession(activity);
    if (alfSession != null && alfSession.getRepositoryInfo() != null
            && alfSession.getRepositoryInfo().getCapabilities() != null
            && alfSession.getRepositoryInfo().getCapabilities().doesSupportLikingNodes()) {
        createMenu = menu.addSubMenu(Menu.NONE, R.id.menu_action_like_group, Menu.FIRST + 150, R.string.like);
        createMenu.setIcon(R.drawable.ic_like);
        createMenu.getItem().setShowAsAction(MenuItem.SHOW_AS_ACTION_IF_ROOM);
        removeActionIfNecessary(menu, createMenu.getItem().getItemId(),
                ConfigurableActionHelper.ACTION_NODE_LIKE);

        createMenu.add(Menu.NONE, R.id.menu_action_like_group_like, Menu.FIRST + 1, R.string.like);
        createMenu.add(Menu.NONE, R.id.menu_action_like_group_unlike, Menu.FIRST + 2, R.string.unlike);
    }

    if (parentFolder != null && ConfigurableActionHelper.isVisible(getActivity(), getAccount(), getSession(),
            parentFolder, ConfigurableActionHelper.ACTION_NODE_DELETE)) {
        mi = menu.add(Menu.NONE, R.id.menu_action_delete, Menu.FIRST + 1000, R.string.delete);
        mi.setIcon(R.drawable.ic_delete);
        mi.setShowAsAction(MenuItem.SHOW_AS_ACTION_IF_ROOM);
        removeActionIfNecessary(menu, mi.getItemId(), ConfigurableActionHelper.ACTION_NODE_DELETE);
    }
}

From source file:com.activiti.android.app.fragments.HelpDialogFragment.java

@Override
public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
    super.onCreateOptionsMenu(menu, inflater);
    menu.clear();/*ww w.  java2 s.c o m*/

    refreshIcon = menu.add(Menu.NONE, R.id.menu_refresh, Menu.FIRST, R.string.refresh);
    refreshIcon.setIcon(R.drawable.ic_refresh_white);
    refreshIcon.setShowAsAction(MenuItem.SHOW_AS_ACTION_IF_ROOM);
}

From source file:org.alfresco.mobile.android.application.fragments.help.HelpDialogFragment.java

@Override
public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
    super.onCreateOptionsMenu(menu, inflater);
    if (!MenuFragmentHelper.canDisplayFragmentMenu(getActivity())) {
        return;/*from  ww  w.  ja  v a2  s  .  com*/
    }
    menu.clear();

    refreshIcon = menu.add(Menu.NONE, R.id.menu_refresh, Menu.FIRST, R.string.refresh);
    refreshIcon.setIcon(R.drawable.ic_refresh);
    refreshIcon.setShowAsAction(MenuItem.SHOW_AS_ACTION_IF_ROOM);
}

From source file:org.alfresco.mobile.android.application.fragments.fileexplorer.LibraryCursorAdapter.java

public void getMenu(Menu menu, File f) {
    MenuItem mi;/*from   ww  w. j  a va 2 s  . com*/

    if (f.isFile()) {
        mi = menu.add(Menu.NONE, R.id.menu_action_share, Menu.FIRST, R.string.share);
        mi.setShowAsAction(MenuItem.SHOW_AS_ACTION_NEVER);

        mi = menu.add(Menu.NONE, R.id.menu_upload, Menu.FIRST + 30, R.string.upload);
        mi.setShowAsAction(MenuItem.SHOW_AS_ACTION_NEVER);
    }

    if (f.canWrite() && downloadPath != null && f.getPath().startsWith(downloadPath)) {
        mi = menu.add(Menu.NONE, R.id.menu_action_delete, Menu.FIRST + 1000, R.string.delete);
        mi.setShowAsAction(MenuItem.SHOW_AS_ACTION_NEVER);
    }

}

From source file:com.nttec.everychan.ui.MainActivity.java

@Override
public boolean onCreateOptionsMenu(Menu menu) {
    if (!MainApplication.getInstance().settings.showSidePanel() && Build.VERSION.SDK_INT < 11) {
        menu.add(Menu.NONE, R.id.menu_open_close_drawer, Menu.FIRST, R.string.menu_open_drawer)
                .setIcon(R.drawable.ic_menu_windows);
    }//from   w  w w  . j a  v  a2  s. c o  m
    if (tabsAdapter != null && tabsAdapter.getSelectedItem() >= 0) {
        TabModel tab = tabsAdapter.getItem(tabsAdapter.getSelectedItem());
        if (canFavorite(tab)) {
            menu.add(Menu.NONE, R.id.menu_favorites, 201, R.string.menu_add_favorites)
                    .setIcon(R.drawable.ic_menu_add_bookmark);
        }
        if (tab.webUrl != null) {
            menu.add(Menu.NONE, R.id.menu_open_browser, 202, R.string.menu_open_browser)
                    .setIcon(R.drawable.ic_menu_browser);
        }
    }
    menu.add(Menu.NONE, R.id.menu_settings, 203, R.string.menu_preferences)
            .setIcon(android.R.drawable.ic_menu_preferences);
    Menu subMenu = menu.addSubMenu(Menu.NONE, R.id.menu_sub_settings, 203, R.string.menu_preferences)
            .setIcon(android.R.drawable.ic_menu_preferences);
    subMenu.add(Menu.NONE, R.id.menu_sub_settings_suspend, 1, R.string.menu_sub_preferences_suspend);
    subMenu.add(Menu.NONE, R.id.menu_sub_settings_autoupdate, 2, R.string.menu_sub_preferences_autoupdate)
            .setCheckable(true);
    subMenu.add(Menu.NONE, R.id.menu_sub_settings_maskpictures, 3, R.string.menu_sub_preferences_maskpictures)
            .setCheckable(true);
    subMenu.add(Menu.NONE, R.id.menu_sub_settings_all, 4, R.string.menu_sub_preferences_all);
    return super.onCreateOptionsMenu(menu);
}

From source file:org.alfresco.mobile.android.application.fragments.config.ConfigMenuEditorFragment.java

@Override
public void onPrepareOptionsMenu(Menu menu) {
    menu.clear();/*from  w ww .  j a  va  2  s.  c  om*/
    menu.add(Menu.NONE, R.id.config_menu_save, Menu.FIRST, "Save");
    menu.add(Menu.NONE, R.id.config_menu_send, Menu.FIRST, "Send");
    menu.add(Menu.NONE, R.id.config_menu_reset, Menu.FIRST, "Reset");
    menu.add(Menu.NONE, R.id.config_menu_clear, Menu.FIRST, "Clear");
}