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:org.akvo.flow.activity.SurveyGroupListActivity.java

@Override
public boolean onContextItemSelected(MenuItem item) {
    AdapterView.AdapterContextMenuInfo info = (AdapterView.AdapterContextMenuInfo) item.getMenuInfo();
    Long id = mAdapter.getItemId(info.position);// This ID is the _id column in the SQLite db
    switch (item.getItemId()) {
    case ITEM_DELETE:
        deleteSurveyGroup(id);//from www.  j ava2  s  .  com
        break;
    }
    return true;
}

From source file:com.boko.vimusic.ui.fragments.ThemeFragment.java

/**
 * {@inheritDoc}//from  www  . j a va 2 s .co m
 */
@Override
public boolean onContextItemSelected(final android.view.MenuItem item) {
    final AdapterContextMenuInfo info = (AdapterContextMenuInfo) item.getMenuInfo();
    switch (item.getItemId()) {
    case OPEN_IN_PLAY_STORE:
        ThemeUtils.openAppPage(getActivity(), mValues[info.position]);
        return true;
    default:
        break;
    }
    return super.onContextItemSelected(item);
}

From source file:com.retroteam.studio.retrostudio.MainActivity.java

@Override
public boolean onContextItemSelected(MenuItem item) {
    AdapterView.AdapterContextMenuInfo info = (AdapterView.AdapterContextMenuInfo) item.getMenuInfo();
    switch (item.getItemId()) {
    case R.id.deleteItem:
        ListView lv = (ListView) findViewById(R.id.songList);
        TextView clickeditem = (TextView) lv.getChildAt(info.position);
        if (deleteProjectFile(clickeditem.getText().toString())) {
            Toast.makeText(this, "Deleted project.", Toast.LENGTH_SHORT).show();
        } else {// w  w w. ja v a2  s .  com
            Toast.makeText(this, "Could not delete project.", Toast.LENGTH_SHORT).show();
        }
        refreshFileList();
        return true;
    default:
        return super.onContextItemSelected(item);
    }
}

From source file:com.telestax.restcomm_olympus.MainFragment.java

@Override
public boolean onContextItemSelected(MenuItem item) {
    AdapterView.AdapterContextMenuInfo info = (AdapterView.AdapterContextMenuInfo) item.getMenuInfo();
    HashMap<String, String> contact = (HashMap) contactList.get(info.position);

    if (item.getTitle().toString().equals("Update Contact")) {
        mCallbacks.onContactUpdate(contact, AddUserDialogFragment.DIALOG_TYPE_UPDATE_CONTACT);
    }/*www  . j  a va 2s.c om*/
    if (item.getTitle().toString().equals("Remove Contact")) {
        contactsController.removeContact(contactList, contact.get("username"), contact.get("sipuri"));
        this.listViewAdapter.notifyDataSetChanged();
    }

    return true;
}

From source file:de.hshannover.f4.trust.ironcontrol.view.list_activities.ListVendorMetadataActivity.java

@Override
public boolean onContextItemSelected(MenuItem item) {
    AdapterContextMenuInfo info = (AdapterContextMenuInfo) item.getMenuInfo();
    String listItemId = Long.toString(info.id);
    switch (item.getItemId()) {
    case REMOVE_ID:
        removeMetadata(listItemId);/*w  ww . ja  v  a2s.co  m*/
        break;
    case EDIT_ID:
        startEditActivity(listItemId);
        break;
    }
    return super.onContextItemSelected(item);
}

From source file:vn.cybersoft.obs.android.fragments.ModeTabFragment.java

@Override
public boolean onContextItemSelected(MenuItem item) {
    final AdapterContextMenuInfo info = (AdapterContextMenuInfo) item.getMenuInfo();
    final int id = (int) info.id;
    // Error check just in case.
    if (id == -1) {
        return super.onContextItemSelected(item);
    }// w w  w . j av a 2  s .  c o m
    switch (item.getItemId()) {
    case R.id.delete_mode:
        // Confirm that the schedule will be deleted.
        new AlertDialog.Builder(getActivity()).setTitle(getString(R.string.delete_mode))
                .setMessage(getString(R.string.delete_mode_confirm))
                .setPositiveButton(android.R.string.ok, new DialogInterface.OnClickListener() {
                    public void onClick(DialogInterface d, int w) {
                        OptimalMode.deleteMode(getActivity().getContentResolver(), id);
                    }
                }).setNegativeButton(android.R.string.cancel, null).show();
        return true;

    case R.id.switch_mode:
        switchToMode(id);
        return true;

    case R.id.edit_mode:
        editMode(id);
        return true;

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

From source file:com.pixellostudio.qqdroid.BaseQuote.java

public boolean onContextItemSelected(MenuItem item) {
    switch (item.getItemId()) {
    case 1://from w  ww .  j a  va2s  . com
        AdapterView.AdapterContextMenuInfo menuInfo = (AdapterView.AdapterContextMenuInfo) item.getMenuInfo();

        Spanned quote = Html.fromHtml((String) view.getAdapter().getItem(menuInfo.position));

        Intent i = new Intent(Intent.ACTION_SEND);
        i.putExtra(Intent.EXTRA_TEXT,
                getBaseContext().getText(R.string.quotefrom) + " " + name + " : " + quote);
        i.setType("text/plain");
        startActivity(Intent.createChooser(i, this.getText(R.string.share)));

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

From source file:com.codebutler.farebot.activities.MainActivity.java

@Override
public boolean onContextItemSelected(MenuItem item) {
    if (item.getItemId() == R.id.delete_card) {
        long id = ((AdapterView.AdapterContextMenuInfo) item.getMenuInfo()).id;
        Uri uri = ContentUris.withAppendedId(CardProvider.CONTENT_URI_CARD, id);
        getContentResolver().delete(uri, null, null);
        return true;
    }/* w w  w.j  a  v a2 s .  c om*/
    return false;
}

From source file:id.nci.stm_9.KeyListPublicFragment.java

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

    // expInfo.id would also return row id of childs, but we always want to get the row id of
    // the group item, thus we are using the following way
    int groupPosition = ExpandableListView.getPackedPositionGroup(expInfo.packedPosition);
    long keyRingRowId = getExpandableListAdapter().getGroupId(groupPosition);

    switch (item.getItemId()) {
    //        case Id.menu.update:
    case 0x21070004:
        long updateKeyId = 0;
        PGPPublicKeyRing updateKeyRing = ProviderHelper.getPGPPublicKeyRingByRowId(mKeyListActivity,
                keyRingRowId);//ww w  .  j  a  va2  s  .  c o m
        if (updateKeyRing != null) {
            updateKeyId = PgpKeyHelper.getMasterKey(updateKeyRing).getKeyID();
        }
        if (updateKeyId == 0) {
            // this shouldn't happen
            return true;
        }

        Intent queryIntent = new Intent(mKeyListActivity, KeyServerQueryActivity.class);
        queryIntent.setAction(KeyServerQueryActivity.ACTION_LOOK_UP_KEY_ID_AND_RETURN);
        queryIntent.putExtra(KeyServerQueryActivity.EXTRA_KEY_ID, updateKeyId);

        // TODO: lookup??
        //            startActivityForResult(queryIntent, Id.request.look_up_key_id);
        startActivityForResult(queryIntent, 0x00007006);

        return true;

    //        case Id.menu.exportToServer:
    case 0x21070005:
        Intent uploadIntent = new Intent(mKeyListActivity, KeyServerUploadActivity.class);
        uploadIntent.setAction(KeyServerUploadActivity.ACTION_EXPORT_KEY_TO_SERVER);
        uploadIntent.putExtra(KeyServerUploadActivity.EXTRA_KEYRING_ROW_ID, (int) keyRingRowId);
        //            startActivityForResult(uploadIntent, Id.request.export_to_server);
        startActivityForResult(uploadIntent, 0x00007007);

        return true;

    //        case Id.menu.signKey:
    //            long keyId = 0;
    //            PGPPublicKeyRing signKeyRing = ProviderHelper.getPGPPublicKeyRingByRowId(
    //                    mKeyListActivity, keyRingRowId);
    //            if (signKeyRing != null) {
    //                keyId = PgpKeyHelper.getMasterKey(signKeyRing).getKeyID();
    //            }
    //            if (keyId == 0) {
    //                // this shouldn't happen
    //                return true;
    //            }
    //
    //            Intent signIntent = new Intent(mKeyListActivity, SignKeyActivity.class);
    //            signIntent.putExtra(SignKeyActivity.EXTRA_KEY_ID, keyId);
    //            startActivity(signIntent);
    //
    //            return true;
    //
    //        case Id.menu.share_qr_code:
    //            // get master key id using row id
    //            long masterKeyId = ProviderHelper.getPublicMasterKeyId(mKeyListActivity, keyRingRowId);
    //
    //            Intent qrCodeIntent = new Intent(mKeyListActivity, ShareActivity.class);
    //            qrCodeIntent.setAction(ShareActivity.ACTION_SHARE_KEYRING_WITH_QR_CODE);
    //            qrCodeIntent.putExtra(ShareActivity.EXTRA_MASTER_KEY_ID, masterKeyId);
    //            startActivityForResult(qrCodeIntent, 0);
    //
    //            return true;
    //
    //        case Id.menu.share_nfc:
    //            // get master key id using row id
    //            long masterKeyId2 = ProviderHelper.getPublicMasterKeyId(mKeyListActivity, keyRingRowId);
    //
    //            Intent nfcIntent = new Intent(mKeyListActivity, ShareNfcBeamActivity.class);
    //            nfcIntent.setAction(ShareNfcBeamActivity.ACTION_SHARE_KEYRING_WITH_NFC);
    //            nfcIntent.putExtra(ShareNfcBeamActivity.EXTRA_MASTER_KEY_ID, masterKeyId2);
    //            startActivityForResult(nfcIntent, 0);
    //
    //            return true;
    //
    //        case Id.menu.share:
    //            // get master key id using row id
    //            long masterKeyId3 = ProviderHelper.getPublicMasterKeyId(mKeyListActivity, keyRingRowId);
    //
    //            Intent shareIntent = new Intent(mKeyListActivity, ShareActivity.class);
    //            shareIntent.setAction(ShareActivity.ACTION_SHARE_KEYRING);
    //            shareIntent.putExtra(ShareActivity.EXTRA_MASTER_KEY_ID, masterKeyId3);
    //            startActivityForResult(shareIntent, 0);
    //
    //            return true;

    default:
        return super.onContextItemSelected(item);

    }
}

From source file:pl.selvin.android.listsyncsample.ui.ListFragment.java

@Override
public boolean onContextItemSelected(android.view.MenuItem item) {
    switch (item.getItemId()) {
    case R.id.menu_item_edit:
        AdapterView.AdapterContextMenuInfo menuInfo = (AdapterView.AdapterContextMenuInfo) item.getMenuInfo();
        Intent intent = new Intent(Intent.ACTION_EDIT,
                ListProvider.getHelper().getItemUri(Database.Item.TABLE_NAME, menuInfo.id), getActivity(),
                EditItemActivity.class);
        startActivity(intent);/*from   ww w  .j av  a2s.  c om*/
        return true;
    case R.id.menu_item_delete:
        menuInfo = (AdapterView.AdapterContextMenuInfo) item.getMenuInfo();
        ConfirmDeleteDialog
                .newInstance(R.string.ui_alert_delete_item,
                        ListProvider.getHelper().getItemUri(Database.Item.TABLE_NAME, menuInfo.id))
                .show(getFragmentManager(), "dialog");
        return true;
    default:
        return super.onOptionsItemSelected(item);
    }
}