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:free.yhc.feeder.ChannelListFragment.java

@Override
public boolean onContextItemSelected(MenuItem mItem) {
    if (!mPrimary || !getMyActivity().isContextMenuOwner(this))
        return false;

    AdapterContextMenuInfo info = (AdapterContextMenuInfo) mItem.getMenuInfo();
    long dbId = getAdapter().getItemInfo_cid(info.position);
    switch (mItem.getItemId()) {
    case R.id.delete:
        onContext_deleteChannel(dbId);//w ww .  ja  v  a 2 s .co m
        return true;

    case R.id.delete_dnfile:
        onContext_deleteDownloaded(dbId);
        return true;

    case R.id.delete_used_dnfile:
        onContext_deleteUsedDownloaded(dbId);
        return true;

    case R.id.change_category:
        onContext_changeCategory(dbId);
        return true;

    case R.id.setting:
        onContext_setting(dbId);
        return true;

    case R.id.pick_icon:
        onContext_pickIcon(dbId);
        return true;
    }
    return false;
}

From source file:com.moonpi.swiftnotes.MainActivity.java

@Override
public boolean onContextItemSelected(MenuItem item) {
    // Get info about long-pressed item
    final AdapterView.AdapterContextMenuInfo info = (AdapterView.AdapterContextMenuInfo) item.getMenuInfo();

    // If delete pressed in context menu, call deleteNote method with position as argument
    if (item.getTitle() == getResources().getString(R.string.action_delete)) {
        deleteNote(this, info.position);

        return true;
    }// w  w w . j a  v a 2  s . co m

    return false;
}

From source file:org.dvbviewer.controller.ui.fragments.ChannelList.java

public boolean onContextItemSelected(MenuItem item) {
    if (item.getMenuInfo() != null) {
        AdapterContextMenuInfo info = (AdapterContextMenuInfo) item.getMenuInfo();
        selectedPosition = info.position;
    }/*from  www  .  ja v a2 s.c o m*/
    Cursor c = mAdapter.getCursor();
    c.moveToPosition(selectedPosition);
    Channel chan = cursorToChannel(c);
    Timer timer;
    switch (item.getItemId()) {
    case R.id.menuTimer:
        timer = cursorToTimer(c);
        if (UIUtils.isTablet(getActivity())) {
            TimerDetails timerdetails = TimerDetails.newInstance();
            Bundle args = new Bundle();
            args.putString(TimerDetails.EXTRA_TITLE, timer.getTitle());
            args.putString(TimerDetails.EXTRA_CHANNEL_NAME, timer.getChannelName());
            args.putLong(TimerDetails.EXTRA_CHANNEL_ID, timer.getChannelId());
            args.putLong(TimerDetails.EXTRA_START, timer.getStart().getTime());
            args.putLong(TimerDetails.EXTRA_END, timer.getEnd().getTime());
            timerdetails.setArguments(args);
            timerdetails.show(getSherlockActivity().getSupportFragmentManager(), TimerDetails.class.getName());
        } else {
            Intent timerIntent = new Intent(getActivity(), TimerDetailsActivity.class);
            timerIntent.putExtra(TimerDetails.EXTRA_TITLE, timer.getTitle());
            timerIntent.putExtra(TimerDetails.EXTRA_CHANNEL_NAME, timer.getChannelName());
            timerIntent.putExtra(TimerDetails.EXTRA_CHANNEL_ID, timer.getChannelId());
            timerIntent.putExtra(TimerDetails.EXTRA_START, timer.getStart().getTime());
            timerIntent.putExtra(TimerDetails.EXTRA_END, timer.getEnd().getTime());
            startActivity(timerIntent);
        }
        return true;
    case R.id.menuStream:
        if (UIUtils.isTablet(getActivity())) {
            StreamConfig cfg = StreamConfig.newInstance();
            Bundle arguments = new Bundle();
            arguments.putInt(StreamConfig.EXTRA_FILE_ID, chan.getPosition());
            arguments.putInt(StreamConfig.EXTRA_FILE_TYPE, StreamConfig.FILE_TYPE_LIVE);
            arguments.putInt(StreamConfig.EXTRA_DIALOG_TITLE_RES, R.string.streamConfig);
            cfg.setArguments(arguments);
            cfg.show(getSherlockActivity().getSupportFragmentManager(), StreamConfig.class.getName());
        } else {
            Intent streamConfig = new Intent(getActivity(), StreamConfigActivity.class);
            streamConfig.putExtra(StreamConfig.EXTRA_FILE_ID, chan.getPosition());
            streamConfig.putExtra(StreamConfig.EXTRA_FILE_TYPE, StreamConfig.FILE_TYPE_LIVE);
            streamConfig.putExtra(StreamConfig.EXTRA_DIALOG_TITLE_RES, R.string.streamConfig);
            startActivity(streamConfig);
        }
        return true;
    case R.id.menuSwitch:
        String switchRequest = ServerConsts.URL_SWITCH_COMMAND + chan.getPosition();
        DVBViewerCommand command = new DVBViewerCommand(switchRequest);
        Thread exexuterTHread = new Thread(command);
        exexuterTHread.start();
        return true;
    case R.id.menuRecord:
        timer = cursorToTimer(c);
        String url = timer.getId() <= 0l ? ServerConsts.URL_TIMER_CREATE : ServerConsts.URL_TIMER_EDIT;
        String title = timer.getTitle();
        String days = String.valueOf(DateUtils.getDaysSinceDelphiNull(timer.getStart()));
        String start = String.valueOf(DateUtils.getMinutesOfDay(timer.getStart()));
        String stop = String.valueOf(DateUtils.getMinutesOfDay(timer.getEnd()));
        String endAction = String.valueOf(timer.getTimerAction());
        List<NameValuePair> params = new ArrayList<NameValuePair>();
        params.add(new BasicNameValuePair("ch", String.valueOf(timer.getChannelId())));
        params.add(new BasicNameValuePair("dor", days));
        params.add(new BasicNameValuePair("encoding", "255"));
        params.add(new BasicNameValuePair("enable", "1"));
        params.add(new BasicNameValuePair("start", start));
        params.add(new BasicNameValuePair("stop", stop));
        params.add(new BasicNameValuePair("title", title));
        params.add(new BasicNameValuePair("endact", endAction));
        if (timer.getId() > 0) {
            params.add(new BasicNameValuePair("id", String.valueOf(timer.getId())));
        }

        String query = URLEncodedUtils.format(params, "utf-8");
        String request = url + query;
        RecordingServiceGet rsGet = new RecordingServiceGet(request);
        Thread executionThread = new Thread(rsGet);
        executionThread.start();
        return true;

    default:
        break;
    }
    return false;
}

From source file:com.gsma.rcs.ri.messaging.OneToOneTalkView.java

@Override
public boolean onContextItemSelected(MenuItem item) {
    AdapterView.AdapterContextMenuInfo info = (AdapterView.AdapterContextMenuInfo) item.getMenuInfo();
    Cursor cursor = (Cursor) (mAdapter.getItem(info.position));
    int providerId = cursor.getInt(cursor.getColumnIndexOrThrow(HistoryLog.PROVIDER_ID));
    String id = cursor.getString(cursor.getColumnIndexOrThrow(HistoryLog.ID));
    if (LogUtils.isActive) {
        Log.d(LOGTAG, "onContextItemSelected Id=".concat(id));
    }//from   ww w  .ja v a 2 s.  c o  m
    try {
        switch (item.getItemId()) {
        case R.id.menu_delete_message:
            switch (providerId) {
            case ChatLog.Message.HISTORYLOG_MEMBER_ID:
                mChatService.deleteMessage(id);
                return true;
            case FileTransferLog.HISTORYLOG_MEMBER_ID:
                mFileTransferService.deleteFileTransfer(id);
                return true;
            }
            break;

        case R.id.menu_resend_message:
            switch (providerId) {
            case ChatLog.Message.HISTORYLOG_MEMBER_ID:
                OneToOneChat chat = mChatService.getOneToOneChat(mContact);
                if (chat != null) {
                    chat.resendMessage(id);
                }
                return true;

            case FileTransferLog.HISTORYLOG_MEMBER_ID:
                FileTransfer fileTransfer = mFileTransferService.getFileTransfer(id);
                if (fileTransfer != null) {
                    fileTransfer.resendTransfer();
                }
                return true;
            }
            break;

        case R.id.menu_display_content:
            switch (providerId) {
            case FileTransferLog.HISTORYLOG_MEMBER_ID:
                String file = cursor.getString(cursor.getColumnIndexOrThrow(HistoryLog.CONTENT));
                Utils.showPicture(this, Uri.parse(file));
                markFileTransferAsRead(cursor, id);
                return true;
            }
            break;

        case R.id.menu_view_detail:
            switch (providerId) {
            case ChatLog.Message.HISTORYLOG_MEMBER_ID:
                ChatMessageLogView.startActivity(this, id);
                return true;
            case FileTransferLog.HISTORYLOG_MEMBER_ID:
                FileTransferLogView.startActivity(this, id);
                return true;
            }
            break;

        case R.id.menu_listen_content:
            if (FileTransferLog.HISTORYLOG_MEMBER_ID == providerId) {
                String file = cursor.getString(cursor.getColumnIndexOrThrow(HistoryLog.CONTENT));
                Utils.playAudio(this, Uri.parse(file));
                markFileTransferAsRead(cursor, id);
                return true;
            }
            break;
        }
        return super.onContextItemSelected(item);

    } catch (RcsGenericException | RcsPermissionDeniedException | RcsPersistentStorageException e) {
        showException(e);
        return true;

    } catch (RcsServiceNotAvailableException e) {
        Utils.displayLongToast(this, getString(R.string.label_service_not_available));
        return true;
    }
}

From source file:com.money.manager.ex.home.HomeFragment.java

private QueryAccountBills getSelectedAccount(android.view.MenuItem item) {
    ExpandableListView.ExpandableListContextMenuInfo info = null;
    ContextMenu.ContextMenuInfo menuInfo = item.getMenuInfo();
    // clicking any context item in child fragments will also come here. We need only
    // the context menu items from the Home fragment.
    if (menuInfo instanceof ExpandableListView.ExpandableListContextMenuInfo) {
        info = (ExpandableListView.ExpandableListContextMenuInfo) menuInfo;
    }//from ww w.  j a v a 2s  .c  o m
    if (info == null)
        return null;

    int groupPos, childPos;
    int type = ExpandableListView.getPackedPositionType(info.packedPosition);
    if (type != ExpandableListView.PACKED_POSITION_TYPE_CHILD)
        return null;

    // Get the account.

    groupPos = ExpandableListView.getPackedPositionGroup(info.packedPosition);
    childPos = ExpandableListView.getPackedPositionChild(info.packedPosition);

    HomeAccountsExpandableAdapter accountsAdapter = (HomeAccountsExpandableAdapter) mExpandableListView
            .getExpandableListAdapter();
    QueryAccountBills account = null;
    try {
        account = (QueryAccountBills) accountsAdapter.getChild(groupPos, childPos);
    } catch (Exception e) {
        Timber.e(e, "getting the selected account id");
    }

    return account;
}

From source file:com.code.android.vibevault.SearchScreen.java

/** Handle user's long-click selection.
*
*///from   w  w w  .j  ava2  s  . c  o m
@Override
public boolean onContextItemSelected(MenuItem item) {
    AdapterContextMenuInfo menuInfo = (AdapterContextMenuInfo) item.getMenuInfo();
    if (menuInfo != null) {
        ArchiveShowObj selShow = (ArchiveShowObj) searchList.getAdapter().getItem(menuInfo.position);
        switch (item.getItemId()) {
        case VibeVault.EMAIL_LINK:
            final Intent emailIntent = new Intent(android.content.Intent.ACTION_SEND);
            emailIntent.setType("plain/text");
            emailIntent.putExtra(android.content.Intent.EXTRA_SUBJECT,
                    "Great show on archive.org: " + selShow.getArtistAndTitle());
            emailIntent.putExtra(android.content.Intent.EXTRA_TEXT,
                    "Hey,\n\nYou should listen to " + selShow.getArtistAndTitle() + ".  You can find it here: "
                            + selShow.getShowURL() + "\n\nSent using VibeVault for Android.");
            startActivity(Intent.createChooser(emailIntent, "Send mail..."));
            return true;
        case VibeVault.SHOW_INFO:
            AlertDialog.Builder ad = new AlertDialog.Builder(this);
            ad.setTitle("Show Info");
            View v = LayoutInflater.from(this).inflate(R.layout.scrollable_dialog, null);
            ((TextView) v.findViewById(R.id.DialogText)).setText(selShow.getSource());
            ad.setPositiveButton("Okay.", new android.content.DialogInterface.OnClickListener() {
                public void onClick(DialogInterface dialog, int arg1) {
                }
            });
            ad.setView(v);
            ad.show();
            return true;
        case (VibeVault.ADD_TO_FAVORITE_LIST):
            VibeVault.db.insertFavoriteShow(selShow);
            return true;
        default:
            return false;
        }
    }
    return false;
}

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

@Override
public boolean onContextItemSelected(MenuItem item) {
    AdapterView.AdapterContextMenuInfo menuInfo = (AdapterView.AdapterContextMenuInfo) item.getMenuInfo();
    switch (item.getItemId()) {
    case R.id.context_menu_move:
        tabsAdapter.setDraggingItem(menuInfo.position);
        return true;
    case R.id.context_menu_copy_url:
        String url = tabsAdapter.getItem(menuInfo.position).webUrl;
        if (url != null) {
            Clipboard.copyText(this, url);
            Toast.makeText(this, getString(R.string.notification_url_copied, url), Toast.LENGTH_LONG).show();
        }//from  ww w  . j  a va2s .c o m
        return true;
    case R.id.context_menu_share_link:
        url = tabsAdapter.getItem(menuInfo.position).webUrl;
        if (url != null) {
            Intent shareIntent = new Intent(Intent.ACTION_SEND);
            shareIntent.setType("text/plain");
            shareIntent.putExtra(Intent.EXTRA_SUBJECT, url);
            shareIntent.putExtra(Intent.EXTRA_TEXT, url);
            startActivity(Intent.createChooser(shareIntent, getString(R.string.share_via)));
        }
        return true;
    case R.id.context_menu_favorites:
        handleFavorite(tabsAdapter.getItem(menuInfo.position));
        return true;
    case R.id.context_menu_autoupdate_background:
        tabsAdapter.getItem(menuInfo.position).autoupdateBackground = !tabsAdapter
                .getItem(menuInfo.position).autoupdateBackground;
        tabsAdapter.notifyDataSetChanged();
        return true;
    case R.id.context_menu_autoupdate_now:
        startService(new Intent(this, TabsTrackerService.class)
                .putExtra(TabsTrackerService.EXTRA_UPDATE_IMMEDIATELY, true));
        return true;
    }
    return false;
}

From source file:org.uguess.android.sysinfo.NetStateManager.java

@Override
public boolean onContextItemSelected(MenuItem item) {
    int pos = ((AdapterContextMenuInfo) item.getMenuInfo()).position;

    if (pos > 0 && pos < getListView().getCount()) {
        ConnectionItem itm = (ConnectionItem) getListView().getItemAtPosition(pos);

        if (itm != null && !TextUtils.isEmpty(itm.remote)) {
            ClipboardManager cm = (ClipboardManager) getActivity().getSystemService(Context.CLIPBOARD_SERVICE);

            if (cm != null) {
                cm.setText(itm.remoteName == null ? itm.remote : itm.remoteName);

                Util.shortToast(getActivity(), R.string.copied_hint);
            }// w  w  w .  j  a  va 2  s.c om
        }

        return true;
    }

    return false;
}

From source file:org.gateshipone.odyssey.activities.OdysseyMainActivity.java

@Override
public boolean onContextItemSelected(MenuItem item) {
    AdapterView.AdapterContextMenuInfo info = (AdapterView.AdapterContextMenuInfo) item.getMenuInfo();

    if (info == null) {
        return super.onContextItemSelected(item);
    }// w w  w  .  ja va  2 s .  c o m

    CurrentPlaylistView currentPlaylistView = (CurrentPlaylistView) findViewById(R.id.now_playing_playlist);

    if (currentPlaylistView != null && mNowPlayingDragStatus == DRAG_STATUS.DRAGGED_UP) {
        switch (item.getItemId()) {
        case R.id.view_current_playlist_action_playnext:
            currentPlaylistView.enqueueTrackAsNext(info.position);
            return true;
        case R.id.view_current_playlist_action_remove:
            currentPlaylistView.removeTrack(info.position);
            return true;
        case R.id.view_current_playlist_action_showalbum:
            String albumKey = currentPlaylistView.getAlbumKey(info.position);
            ArrayList<String> albumInformations = MusicLibraryHelper.getAlbumInformationFromKey(albumKey, this);
            if (albumInformations.size() == 3) {
                View coordinatorLayout = findViewById(R.id.main_coordinator_layout);
                coordinatorLayout.setVisibility(View.VISIBLE);

                NowPlayingView nowPlayingView = (NowPlayingView) findViewById(R.id.now_playing_layout);
                if (nowPlayingView != null) {
                    nowPlayingView.minimize();
                }
                onAlbumSelected(albumKey, albumInformations.get(0), albumInformations.get(1),
                        albumInformations.get(2));
            }
            return true;
        case R.id.view_current_playlist_action_showartist:
            String artistTitle = currentPlaylistView.getArtistTitle(info.position);
            long artistID = MusicLibraryHelper.getArtistIDFromName(artistTitle, this);

            View coordinatorLayout = findViewById(R.id.main_coordinator_layout);
            coordinatorLayout.setVisibility(View.VISIBLE);

            NowPlayingView nowPlayingView = (NowPlayingView) findViewById(R.id.now_playing_layout);
            if (nowPlayingView != null) {
                nowPlayingView.minimize();
            }
            onArtistSelected(artistTitle, artistID);
            return true;
        default:
            return super.onContextItemSelected(item);
        }
    }

    return super.onContextItemSelected(item);
}

From source file:net.sourceforge.kalimbaradio.androidapp.activity.DownloadActivity.java

@Override
public boolean onContextItemSelected(MenuItem menuItem) {
    AdapterView.AdapterContextMenuInfo info = (AdapterView.AdapterContextMenuInfo) menuItem.getMenuInfo();
    DownloadFile downloadFile = (DownloadFile) playlistView.getItemAtPosition(info.position);
    return menuItemSelected(menuItem.getItemId(), downloadFile) || super.onContextItemSelected(menuItem);
}