Example usage for android.view MenuItem getMenuInfo

List of usage examples for android.view MenuItem getMenuInfo

Introduction

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

Prototype

public ContextMenuInfo getMenuInfo();

Source Link

Document

Gets the extra information linked to this menu item.

Usage

From source file:net.potterpcs.recipebook.RecipeListFragment.java

public void onTagItemSelected(MenuItem item) {
    AdapterContextMenuInfo info = (AdapterContextMenuInfo) item.getMenuInfo();
    //      Log.i(TAG, "tag option selected, id=" + info.id);
    RecipeBookActivity activity = (RecipeBookActivity) getActivity();
    FragmentTransaction ft = activity.getSupportFragmentManager().beginTransaction();
    Recipe r = ((RecipeBook) activity.getApplication()).getData().getSingleRecipeObject(info.id);
    TagRecipeDialog trd = TagRecipeDialog.newInstance(r.id);
    trd.show(ft, "dialog");
}

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

@Override
public boolean onContextItemSelected(MenuItem item) {
    int position = ((AdapterView.AdapterContextMenuInfo) item.getMenuInfo()).position;
    Object listItem = adapter.getItem(position);
    if (listItem instanceof Database.HistoryEntry) {
        Database database = MainApplication.getInstance().database;
        Database.HistoryEntry entry = (Database.HistoryEntry) listItem;
        switch (item.getItemId()) {
        case R.id.context_menu_remove_history:
            database.removeHistory(entry.chan, entry.board, entry.boardPage, entry.thread);
            adapter.remove(entry);// ww w . j ava  2 s  . co m
            break;
        case R.id.context_menu_open_browser:
            UrlHandler.launchExternalBrowser(activity, entry.url);
            break;
        case R.id.context_menu_favorites_from_fragment:
            if (database.isFavorite(entry.chan, entry.board, entry.boardPage, entry.thread)) {
                database.removeFavorite(entry.chan, entry.board, entry.boardPage, entry.thread);
            } else {
                database.addFavorite(entry.chan, entry.board, entry.boardPage, entry.thread, entry.title,
                        entry.url);
            }
        }
        return true;
    }
    return false;
}

From source file:com.sim2dial.dialer.ChatListFragment.java

@Override
public boolean onContextItemSelected(MenuItem item) {
    AdapterContextMenuInfo info = (AdapterContextMenuInfo) item.getMenuInfo();
    if (info == null || info.targetView == null) {
        return false;
    }/*from   www . j a  v a 2s. c om*/
    String sipUri = (String) info.targetView.getTag();

    LinphoneActivity.instance().removeFromChatList(sipUri);
    mConversations = LinphoneActivity.instance().getChatList();
    mDrafts = LinphoneActivity.instance().getDraftChatList();
    mConversations.removeAll(mDrafts);
    hideAndDisplayMessageIfNoChat();
    return true;
}

From source file:com.torygaurnier.openpalette.MainFragment.java

/**
 * Color action is selected./*from   www.ja va  2s. c  om*/
 */
public boolean onContextItemSelected(MenuItem item) {
    int position = (int) ((AdapterView.AdapterContextMenuInfo) item.getMenuInfo()).id;
    final Palette selected_palette = palette_list.getSelectedPalette();
    final HexColor color = selected_palette.getColor(position);

    switch (item.getItemId()) {
    case R.id.copyHexAction:
        String hex = color.getHex();
        clip = ClipData.newPlainText("HEX", hex);
        clipboard.setPrimaryClip(clip);
        Msg.log(Msg.INFO, "onContextItemSelected()", hex + " copied to clipboard");
        return true;

    case R.id.copyRgbAction:
        String rgb = "" + color.getRed() + ", " + color.getGreen() + ", " + color.getBlue();
        clip = ClipData.newPlainText("RGB", rgb);
        clipboard.setPrimaryClip(clip);
        Msg.log(Msg.INFO, "onContextItemSelected()", rgb + " copied to clipboard");
        return true;

    case R.id.copyHsvAction:
        String hsv = "" + color.getHue() + ", " + color.getSaturation() + ", " + color.getValue();
        clip = ClipData.newPlainText("HSV", hsv);
        clipboard.setPrimaryClip(clip);
        Msg.log(Msg.INFO, "onContextItemSelected()", hsv + " copied to clipboard");
        return true;

    case R.id.duplicateColorAction:
        if (color.getName() != null) {
            selected_palette.add(new HexColor(color.getHex(), color.getName()));
        } else {
            selected_palette.add(new HexColor(color.getHex()));
        }

        Data.getInstance().save();
        return true;

    case R.id.editColorAction:
        new ColorChooserDialog(activity).show(color);
        return true;

    case R.id.deleteColorAction:
        selected_palette.remove(color);
        return true;

    default:
        return super.onContextItemSelected(item);
    }
}

From source file:org.videolan.vlc.gui.audio.AudioAlbumFragment.java

@Override
public boolean onContextItemSelected(MenuItem menu) {
    if (!getUserVisibleHint())
        return super.onContextItemSelected(menu);

    AdapterContextMenuInfo info = (AdapterContextMenuInfo) menu.getMenuInfo();
    if (info != null && handleContextItemSelected(menu, info.position))
        return true;
    return super.onContextItemSelected(menu);
}

From source file:org.gateshipone.malp.application.fragments.serverfragments.SavedPlaylistsFragment.java

/**
 * Hook called when an menu item in the context menu is selected.
 *
 * @param item The menu item that was selected.
 * @return True if the hook was consumed here.
 *///from   w  w  w. j  a v a  2  s.c  o m
@Override
public boolean onContextItemSelected(MenuItem item) {
    AdapterView.AdapterContextMenuInfo info = (AdapterView.AdapterContextMenuInfo) item.getMenuInfo();

    if (info == null) {
        return super.onContextItemSelected(item);
    }

    final MPDPlaylist playlist = (MPDPlaylist) mPlaylistAdapter.getItem(info.position);
    switch (item.getItemId()) {
    case R.id.action_add_playlist:
        MPDQueryHandler.loadPlaylist(playlist.getPath());
        return true;
    case R.id.action_remove_playlist:
        final AlertDialog.Builder removeListBuilder = new AlertDialog.Builder(getContext());
        removeListBuilder.setTitle(getContext().getString(R.string.action_delete_playlist));
        removeListBuilder.setMessage(getContext().getString(R.string.dialog_message_delete_playlist) + ' '
                + playlist.getSectionTitle() + '?');
        removeListBuilder.setPositiveButton(R.string.dialog_action_yes, new DialogInterface.OnClickListener() {
            @Override
            public void onClick(DialogInterface dialog, int which) {
                MPDQueryHandler.removePlaylist(playlist.getPath());
                mPlaylistAdapter.swapModel(null);
                getLoaderManager().destroyLoader(0);
                getLoaderManager().initLoader(0, getArguments(), SavedPlaylistsFragment.this);
            }
        });
        removeListBuilder.setNegativeButton(R.string.dialog_action_no, new DialogInterface.OnClickListener() {
            @Override
            public void onClick(DialogInterface dialog, int which) {

            }
        });
        removeListBuilder.create().show();

        return true;
    case R.id.action_play_playlist:
        MPDQueryHandler.playPlaylist(playlist.getPath());
        return true;
    default:
        return super.onContextItemSelected(item);
    }
}

From source file:dev.drsoran.moloko.fragments.TaskListsFragment.java

@Override
public boolean onContextItemSelected(android.view.MenuItem item) {
    final ExpandableListContextMenuInfo info = (ExpandableListContextMenuInfo) item.getMenuInfo();

    switch (item.getItemId()) {
    case R.id.ctx_menu_expand:
        getExpandableListView().expandGroup(ExpandableListView.getPackedPositionGroup(info.packedPosition));
        return true;

    case R.id.ctx_menu_collapse:
        getExpandableListView().collapseGroup(ExpandableListView.getPackedPositionGroup(info.packedPosition));
        return true;

    case R.id.ctx_menu_delete_list:
        if (listener != null)
            listener.deleteList(ExpandableListView.getPackedPositionGroup(info.packedPosition));
        return true;

    case R.id.ctx_menu_rename_list:
        if (listener != null)
            listener.renameList(ExpandableListView.getPackedPositionGroup(info.packedPosition));
        return true;

    case R.id.ctx_menu_set_default_list:
        setAsDefaultList(ExpandableListView.getPackedPositionGroup(info.packedPosition));
        return true;

    case R.id.ctx_menu_unset_default_list:
        resetDefaultList();//from  w  w w  .j  a v  a2s .c  o m
        return true;

    default:
        return super.onContextItemSelected(item);
    }
}

From source file:com.royclarkson.springagram.PhotoListFragment.java

@Override
public boolean onContextItemSelected(MenuItem item) {
    AdapterView.AdapterContextMenuInfo info = (AdapterView.AdapterContextMenuInfo) item.getMenuInfo();
    switch (item.getItemId()) {
    case R.id.action_add_to_gallery:
        addToGallery(info.position);//from  www .  j av a2 s . c  om
        return true;
    case R.id.action_delete:
        deletePhoto(info.position);
        return true;
    default:
        return super.onContextItemSelected(item);
    }
}

From source file:com.runye.express.chat.activity.ContactlistFragment.java

@Override
public boolean onContextItemSelected(MenuItem item) {
    if (item.getItemId() == R.id.delete_contact) {
        User tobeDeleteUser = adapter.getItem(((AdapterContextMenuInfo) item.getMenuInfo()).position);
        // ?/* w  ww .j  a  v  a  2 s  .c  o  m*/
        deleteContact(tobeDeleteUser);
        // ?
        InviteMessgeDao dao = new InviteMessgeDao(getActivity());
        dao.deleteMessage(tobeDeleteUser.getUsername());
        return true;
    }
    return super.onContextItemSelected(item);
}

From source file:net.ustyugov.jtalk.activity.muc.MucUsers.java

@Override
public boolean onContextItemSelected(android.view.MenuItem item) {
    AdapterContextMenuInfo info = (AdapterContextMenuInfo) item.getMenuInfo();
    TextView v = (TextView) info.targetView.findViewById(R.id.item);
    String jid = v.getText().toString();

    switch (item.getItemId()) {
    case CONTEXT_REMOVE:
        MUCAdmin.Item i = new MUCAdmin.Item("none", null);
        i.setJid(jid);/* w  w w. j  av a 2  s .c o  m*/

        MUCAdmin admin = new MUCAdmin();
        admin.setType(IQ.Type.SET);
        admin.setTo(muc.getRoom());
        admin.addItem(i);

        JTalkService.getInstance().getConnection(account).sendPacket(admin);
        update();
        break;
    case CONTEXT_EDIT:
        newJid = false;
        editedJid = jid;
        showDialog();
        break;
    }
    return true;
}