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:piuk.blockchain.android.ui.SendingAddressesFragment.java

@Override
public boolean onContextItemSelected(final MenuItem item) {
    final AdapterContextMenuInfo menuInfo = (AdapterContextMenuInfo) item.getMenuInfo();

    switch (item.getItemId()) {
    case R.id.sending_addresses_context_send: {
        final Cursor cursor = (Cursor) adapter.getItem(menuInfo.position);
        final String address = cursor.getString(cursor.getColumnIndexOrThrow(AddressBookProvider.KEY_ADDRESS));
        handleSend(address);//  w  ww.  ja  v  a  2 s . c  om
        return true;
    }

    case R.id.sending_addresses_context_edit: {
        final Cursor cursor = (Cursor) adapter.getItem(menuInfo.position);
        final String address = cursor.getString(cursor.getColumnIndexOrThrow(AddressBookProvider.KEY_ADDRESS));
        EditAddressBookEntryFragment.edit(getFragmentManager(), address);
        return true;
    }

    case R.id.sending_addresses_context_remove: {
        final Cursor cursor = (Cursor) adapter.getItem(menuInfo.position);
        final String address = cursor.getString(cursor.getColumnIndexOrThrow(AddressBookProvider.KEY_ADDRESS));
        handleRemove(address);
        return true;
    }

    case R.id.sending_addresses_context_show_qr: {
        final Cursor cursor = (Cursor) adapter.getItem(menuInfo.position);
        Address address;
        try {
            address = new Address(Constants.NETWORK_PARAMETERS,
                    cursor.getString(cursor.getColumnIndexOrThrow(AddressBookProvider.KEY_ADDRESS)));

            final String uri = BitcoinURI.convertToBitcoinURI(address, null, null, null);
            final int size = (int) (256 * getResources().getDisplayMetrics().density);
            new QrDialog(activity, WalletUtils.getQRCodeBitmap(uri, size)).show();
            return true;
        } catch (Exception e) {
            e.printStackTrace();
            return false;
        }
    }

    case R.id.sending_addresses_context_copy_to_clipboard: {
        final Cursor cursor = (Cursor) adapter.getItem(menuInfo.position);
        final String address = cursor.getString(cursor.getColumnIndexOrThrow(AddressBookProvider.KEY_ADDRESS));
        handleCopyToClipboard(address);
        return true;
    }

    default:
        return false;
    }
}

From source file:eu.trentorise.smartcampus.eb.fragments.ExperiencesListFragment.java

@Override
public void onCreateContextMenu(ContextMenu menu, View view, ContextMenuInfo menuInfo) {
    menu.setHeaderTitle(R.string.exp_menu_header);
    android.view.MenuInflater inflater = getSherlockActivity().getMenuInflater();
    inflater.inflate(R.menu.exp_list_menu, menu);
    MenuItem item = menu.findItem(R.id.expmenu_share);
    if (item != null) {
        AdapterContextMenuInfo info = (AdapterContextMenuInfo) item.getMenuInfo();
        Experience exp = experiencesList.get(info.position);
        item.setEnabled(exp.getEntityId() > 0).setVisible(exp.getEntityId() > 0);
    }//from   ww  w  .ja  v a  2s .co  m
}

From source file:com.ratebeer.android.gui.fragments.OfflineRatingsFragment.java

@Override
public boolean onContextItemSelected(android.view.MenuItem item) {
    AdapterContextMenuInfo acmi = (AdapterContextMenuInfo) item.getMenuInfo();
    final OfflineRating rating = (OfflineRating) ratingsView.getItemAtPosition(acmi.position);
    new ConfirmDialogFragment(new OnDialogResult() {
        @Override// w ww.  ja v  a2 s . c  om
        public void onConfirmed() {
            deleteRating(rating);
            loadRatings();
        }
    }, R.string.rate_offline_confirmdelete, rating.getBeerName()).show(getFragmentManager(), "dialog");
    return super.onContextItemSelected(item);
}

From source file:de.grundid.plusrad.MainActivity.java

@Override
public boolean onContextItemSelected(MenuItem item) {
    AdapterView.AdapterContextMenuInfo info = (AdapterView.AdapterContextMenuInfo) item.getMenuInfo();
    switch (item.getItemId()) {
    case CONTEXT_RETRY:
        retryTripUpload(info.id);/*from  ww w .j ava 2 s  .c o  m*/
        return true;
    case CONTEXT_DELETE:
        deleteTrip(info.id);
        return true;
    default:
        return super.onContextItemSelected(item);
    }
}

From source file:ivl.android.moneybalance.CalculationListActivity.java

@Override
public boolean onContextItemSelected(MenuItem item) {
    AdapterView.AdapterContextMenuInfo info = (AdapterView.AdapterContextMenuInfo) item.getMenuInfo();
    cursor.moveToPosition(info.position);
    long calculationId = cursor.getLong(0);

    if (item.getItemId() == ITEM_DELETE) {
        confirmAndDelete(dataSource.get(calculationId));
        return true;
    } else if (item.getItemId() == ITEM_SUMMARY) {
        Intent intent = new Intent(this, SummaryActivity.class);
        intent.putExtra(ExpenseListActivity.PARAM_CALCULATION_ID, calculationId);
        startActivity(intent);/*from   w w  w.j  a v  a2 s.c o  m*/
    } else {
        return false;
    }
    return true;
}

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

@Override
public boolean onContextItemSelected(MenuItem item) {
    AdapterView.AdapterContextMenuInfo info = (AdapterView.AdapterContextMenuInfo) item.getMenuInfo();
    switch (item.getItemId()) {
    case R.id.action_remove_from_gallery:
        removeFromGallery(info.position);
        return true;
    default:/* w  w  w  . ja  v a  2  s.c o  m*/
        return super.onContextItemSelected(item);
    }
}

From source file:org.akvo.flow.ui.fragment.ResponseListFragment.java

@Override
public boolean onContextItemSelected(MenuItem item) {
    AdapterView.AdapterContextMenuInfo info = (AdapterView.AdapterContextMenuInfo) item.getMenuInfo();
    Long surveyInstanceId = mAdapter.getItemId(info.position);// This ID is the _id column in the SQLite db
    switch (item.getItemId()) {
    case DELETE_ONE:
        deleteSurveyInstance(surveyInstanceId);
        break;//from ww  w  .  j a v a  2s  .com
    case VIEW_HISTORY:
        viewSurveyInstanceHistory(surveyInstanceId);
        break;
    }
    return true;
}

From source file:org.gateshipone.odyssey.fragments.AllTracksFragment.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 ww  w .  j av a 2 s .co m
@Override
public boolean onContextItemSelected(MenuItem item) {
    AdapterView.AdapterContextMenuInfo info = (AdapterView.AdapterContextMenuInfo) item.getMenuInfo();

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

    switch (item.getItemId()) {
    case R.id.fragment_all_tracks_action_enqueue:
        enqueueTrack(info.position, false);
        return true;
    case R.id.fragment_all_tracks_action_enqueueasnext:
        enqueueTrack(info.position, true);
        return true;
    case R.id.fragment_all_tracks_action_play:
        playTrack(info.position);
        return true;
    case R.id.fragment_all_tracks_showartist:
        showArtist(info.position);
        return true;
    default:
        return super.onContextItemSelected(item);
    }
}

From source file:org.klnusbaum.udj.PlaylistFragment.java

@Override
public boolean onContextItemSelected(MenuItem item) {
    AdapterView.AdapterContextMenuInfo info = (AdapterView.AdapterContextMenuInfo) item.getMenuInfo();
    switch (item.getItemId()) {
    case R.id.share:
        shareSong(info.position);//from   w ww. j ava 2  s  .c  o m
        return true;
    case R.id.remove_song:
        removeSong(info.position);
        return true;
    case R.id.set_current_song:
        setCurrentSong(info.position);
        return true;
    default:
        return super.onContextItemSelected(item);
    }
}

From source file:de.tubs.ibr.dtn.daemon.NeighborListFragment.java

@Override
public boolean onContextItemSelected(MenuItem item) {
    AdapterView.AdapterContextMenuInfo info = (AdapterView.AdapterContextMenuInfo) item.getMenuInfo();
    NeighborListAdapter nla = (NeighborListAdapter) getListAdapter();
    Node n = (Node) nla.getItem(info.position);

    switch (item.getItemId()) {
    case R.id.itemConnect: {
        // initiate connection via intent
        final Intent intent = new Intent(getActivity(), DaemonService.class);
        intent.setAction(de.tubs.ibr.dtn.service.DaemonService.ACTION_INITIATE_CONNECTION);
        intent.putExtra(de.tubs.ibr.dtn.Intent.EXTRA_ENDPOINT, n.endpoint.toString());
        getActivity().startService(intent);
        return true;
    }/*w w  w  . ja  va  2 s . com*/

    case R.id.itemKeyInfo: {
        // open keyinfo panel
        final Intent intent = new Intent(getActivity(), KeyInformationActivity.class);
        intent.putExtra(de.tubs.ibr.dtn.Intent.EXTRA_ENDPOINT, (Parcelable) n.endpoint);
        getActivity().startActivity(intent);
        return true;
    }

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