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.czlee.debatekeeper.PrepTimeBellsEditActivity.java

@Override
public boolean onContextItemSelected(MenuItem item) {
    AdapterContextMenuInfo info = (AdapterContextMenuInfo) item.getMenuInfo();
    switch (item.getItemId()) {
    case R.id.prepTimeBellsEditor_contextMenu_edit:
        Bundle args = mPtbm.getBellBundle(info.position);
        args.putInt(KEY_INDEX, info.position);
        DialogFragment fragment = new DialogAddOrEditBellFragment();
        fragment.setArguments(args);/*from www  .  j a va  2s .  com*/
        fragment.show(getSupportFragmentManager(), DIALOG_TAG_EDIT_BELL);
        return true;
    case R.id.prepTimeBellsEditor_contextMenu_delete:
        mPtbm.deleteBell(info.position);
        refreshBellsList();
        return true;
    default:
        return super.onContextItemSelected(item);
    }
}

From source file:de.eidottermihi.rpicheck.activity.CustomCommandActivity.java

@Override
public boolean onContextItemSelected(android.view.MenuItem item) {
    AdapterView.AdapterContextMenuInfo info = (AdapterView.AdapterContextMenuInfo) item.getMenuInfo();
    LOGGER.debug("Context item selected for command id {}.", info.id);
    int menuItemIndex = item.getItemId();
    switch (menuItemIndex) {
    case 1:/*from  w  ww .  j ava  2 s. c o m*/
        Intent newCommandIntent = new Intent(CustomCommandActivity.this, NewCommandActivity.class);
        newCommandIntent.putExtras(this.getIntent().getExtras());
        newCommandIntent.putExtra(NewCommandActivity.CMD_KEY_EDIT, info.id);
        this.startActivityForResult(newCommandIntent, NewCommandActivity.REQUEST_EDIT);
        break;
    case 2:
        this.deleteCommand(info.id);
        break;
    case 3:
        this.runCommand(info.id);
        break;
    default:
        break;
    }
    return true;
}

From source file:org.lyricue.android.PlaylistFragment.java

@Override
public boolean onContextItemSelected(android.view.MenuItem item) {
    if (item.getGroupId() == 1) {
        AdapterView.AdapterContextMenuInfo info = (AdapterView.AdapterContextMenuInfo) item.getMenuInfo();

        long itemid = item.getItemId();

        if (item.getItemId() == 0) {
            Log.i(TAG, "show item:" + itemid);
            activity.ld.runCommand_noreturn("display", String.valueOf(itemid), "");
        } else if (item.getItemId() == 1) {
            Log.i(TAG, "remove item:" + itemid);
            if (activity.hosts != null)
                new RemoveItemTask().execute(itemid);
        }/*from  w  w w. j  av a2s.  co  m*/
        return true;
    } else {
        return false;
    }

}

From source file:org.mozilla.gecko.home.RemoteTabsBaseFragment.java

@Override
public boolean onContextItemSelected(MenuItem item) {
    if (super.onContextItemSelected(item)) {
        // HomeFragment was able to handle to selected item.
        return true;
    }/*from   w  ww  . j  a  va2 s.c o m*/

    final ContextMenu.ContextMenuInfo menuInfo = item.getMenuInfo();
    if (!(menuInfo instanceof RemoteTabsClientContextMenuInfo)) {
        return false;
    }

    final RemoteTabsClientContextMenuInfo info = (RemoteTabsClientContextMenuInfo) menuInfo;

    final int itemId = item.getItemId();
    if (itemId == R.id.home_remote_tabs_hide_client) {
        sState.setClientHidden(info.client.guid, true);
        getLoaderManager().restartLoader(LOADER_ID_REMOTE_TABS, null, mCursorLoaderCallbacks);
        return true;
    }

    if (itemId == R.id.home_remote_tabs_show_client) {
        sState.setClientHidden(info.client.guid, false);
        getLoaderManager().restartLoader(LOADER_ID_REMOTE_TABS, null, mCursorLoaderCallbacks);
        return true;
    }

    return false;
}

From source file:com.tbay.android.FrequentSMS.MainActivity.java

@Override
public boolean onContextItemSelected(MenuItem item) {
    AdapterView.AdapterContextMenuInfo info = (AdapterView.AdapterContextMenuInfo) item.getMenuInfo();
    switch (item.getItemId()) {
    case R.id.edit:
        //editNote(info.id);
        return true;
    case R.id.show:
        RadioGroup rg = (RadioGroup) findViewById(R.id.whichSMS);
        int rbid = rg.getCheckedRadioButtonId();

        RadioButton rb = (RadioButton) findViewById(rbid);

        int position = rg.indexOfChild(rb);

        Toast.makeText(MainActivity.this, "Telefon nummer: " + Integer.toString(position), Toast.LENGTH_LONG)
                .show();/*from w ww  .ja  v  a  2s.c o  m*/
        return true;
    default:
        return super.onContextItemSelected(item);
    }
}

From source file:com.dnielfe.manager.AppManager.java

@Override
public boolean onContextItemSelected(MenuItem item) {
    AdapterContextMenuInfo info = (AdapterContextMenuInfo) item.getMenuInfo();
    int index = info.position;
    String packagename = mAppList.get(index).packageName;

    switch (item.getItemId()) {
    case ID_LAUNCH:
        Intent i = pm.getLaunchIntentForPackage(packagename);
        startActivity(i);/*from w  ww  .ja  v  a  2 s .  c om*/
        break;

    case ID_MANAGE:
        startActivity(new Intent(android.provider.Settings.ACTION_APPLICATION_DETAILS_SETTINGS,
                Uri.parse("package:" + packagename)));
        break;

    case ID_UNINSTALL:
        Intent i1 = new Intent(Intent.ACTION_DELETE);
        i1.setData(Uri.parse("package:" + packagename));
        startActivity(i1);
        get_downloaded_apps();
        break;

    case ID_MARKET:
        Intent intent1 = new Intent(Intent.ACTION_VIEW);
        intent1.setData(Uri.parse("market://details?id=" + packagename));
        startActivity(intent1);
        break;

    case ID_SEND:
        try {
            ApplicationInfo info1 = pm.getApplicationInfo(packagename, 0);
            String source_dir = info1.sourceDir;
            File file = new File(source_dir);
            Uri uri11 = Uri.fromFile(file.getAbsoluteFile());

            Intent infointent = new Intent(Intent.ACTION_SEND);
            infointent.setType("application/zip");
            infointent.putExtra(Intent.EXTRA_STREAM, uri11);
            startActivity(Intent.createChooser(infointent, getString(R.string.share)));
        } catch (Exception e) {
            Toast.makeText(AppManager.this, "Error", Toast.LENGTH_SHORT).show();
        }
        break;
    }
    return false;
}

From source file:rtandroid.benchmark.ui.BenchmarkFragment.java

@Override
public boolean onContextItemSelected(MenuItem item) {
    TestCaseDialog dialog;/*ww  w .  ja  v a 2 s.  c  om*/

    AdapterView.AdapterContextMenuInfo info = (AdapterView.AdapterContextMenuInfo) item.getMenuInfo();
    TestCaseItem testCaseView = (TestCaseItem) info.targetView;
    TestCase testCase = testCaseView.getTestCase();

    switch (item.getItemId()) {
    case R.id.menu_edit:
        dialog = TestCaseDialog.newInstance(testCase);
        dialog.setTargetFragment(this, 0);
        dialog.show(getFragmentManager(), "");
        return true;

    case R.id.menu_delete:
        mTestCases.remove(testCase);
        mTestCaseAdapter.notifyDataSetChanged();
        mListener.saveTestCases(mTestCases);
        return true;

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

From source file:com.orangelabs.rcs.ri.messaging.chat.group.GroupChatList.java

@Override
public boolean onContextItemSelected(MenuItem item) {
    /* Get selected item */
    AdapterContextMenuInfo info = (AdapterContextMenuInfo) item.getMenuInfo();
    Cursor cursor = (Cursor) (mListView.getAdapter()).getItem(info.position);
    String chatId = cursor.getString(cursor.getColumnIndexOrThrow(ChatLog.GroupChat.CHAT_ID));
    if (LogUtils.isActive) {
        Log.d(LOGTAG, "onContextItemSelected chatId=".concat(chatId));
    }/*from   ww  w . j  av  a  2s. c  o m*/
    switch (item.getItemId()) {
    case CHAT_MENU_ITEM_OPEN:
        if (!isServiceConnected(RcsServiceName.CHAT)) {
            showMessage(R.string.label_service_not_available);
            return true;
        }
        if (LogUtils.isActive) {
            Log.d(LOGTAG, "Open group chat for chatId=".concat(chatId));
        }
        /* Open group chat view */
        GroupChatView.openGroupChat(this, chatId);
        return true;

    case CHAT_MENU_ITEM_DELETE:
        if (!isServiceConnected(RcsServiceName.CHAT)) {
            showMessage(R.string.label_service_not_available);
            return true;
        }
        /* Delete messages for chat ID */
        if (LogUtils.isActive) {
            Log.d(LOGTAG, "Delete messages for chatId=".concat(chatId));
        }
        try {
            if (!mGroupChatListenerSet) {
                mChatService.addEventListener(mGroupChatListener);
                mGroupChatListenerSet = true;
            }
            mChatService.deleteGroupChat(chatId);
        } catch (RcsServiceException e) {
            showExceptionThenExit(e);
        }
        return true;
    default:
        return super.onContextItemSelected(item);
    }
}

From source file:org.gateshipone.malp.application.fragments.serverfragments.SearchFragment.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 . ja  v  a2s  . c  om*/
@Override
public boolean onContextItemSelected(MenuItem item) {
    AdapterView.AdapterContextMenuInfo info = (AdapterView.AdapterContextMenuInfo) item.getMenuInfo();

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

    MPDTrack track = (MPDTrack) mFileAdapter.getItem(info.position);

    mListView.requestFocus();

    switch (item.getItemId()) {
    case R.id.action_song_play:
        MPDQueryHandler.playSong(track.getPath());
        return true;
    case R.id.action_song_enqueue:
        MPDQueryHandler.addPath(track.getPath());
        return true;
    case R.id.action_song_play_next:
        MPDQueryHandler.playSongNext(track.getPath());
        return true;
    case R.id.action_add_to_saved_playlist:
        // open dialog in order to save the current playlist as a playlist in the mediastore
        ChoosePlaylistDialog choosePlaylistDialog = new ChoosePlaylistDialog();
        Bundle args = new Bundle();
        args.putBoolean(ChoosePlaylistDialog.EXTRA_SHOW_NEW_ENTRY, true);
        choosePlaylistDialog.setCallback(
                new AddPathToPlaylist((MPDFileEntry) mFileAdapter.getItem(info.position), getContext()));
        choosePlaylistDialog.setArguments(args);
        choosePlaylistDialog.show(((AppCompatActivity) getContext()).getSupportFragmentManager(),
                "ChoosePlaylistDialog");
        return true;
    case R.id.action_add_album:
        MPDQueryHandler.addArtistAlbum(track.getTrackAlbum(), "", track.getTrackAlbumMBID());
        return true;
    case R.id.action_play_album:
        MPDQueryHandler.playArtistAlbum(track.getTrackAlbum(), "", track.getTrackAlbumMBID());
        return true;
    case R.id.action_add_artist:
        MPDQueryHandler.addArtist(track.getTrackArtist());
        return true;
    case R.id.action_play_artist:
        MPDQueryHandler.playArtist(track.getTrackArtist());
        return true;
    default:
        return super.onContextItemSelected(item);
    }
}