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.onebusaway.android.ui.MyStopListFragmentBase.java

@Override
public boolean onContextItemSelected(MenuItem item) {
    AdapterContextMenuInfo info = (AdapterContextMenuInfo) item.getMenuInfo();
    switch (item.getItemId()) {
    case CONTEXT_MENU_DEFAULT:
        // Fake a click
        onListItemClick(getListView(), info.targetView, info.position, info.id);
        return true;
    case CONTEXT_MENU_SHOW_ON_MAP:
        showOnMap(getListView(), info.position);
        return true;
    case CONTEXT_MENU_CREATE_SHORTCUT:
        StopData stopData = getStopData(getListView(), info.position);
        final Intent shortcutIntent = UIUtils.makeShortcut(getActivity(), stopData.uiName,
                stopData.getArrivalsList().getIntent());
        shortcutIntent.setAction(INSTALL_SHORTCUT);
        shortcutIntent.setFlags(0);//from   ww  w  .j  av  a  2 s.  c o  m
        getActivity().sendBroadcast(shortcutIntent);
        return true;
    default:
        return super.onContextItemSelected(item);
    }
}

From source file:com.racoon.ampdroid.views.SelectedSongsView.java

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

    switch (item.getItemId()) {
    case R.id.contextMenuAdd:
        controller.getPlayNow().add(controller.getSongs().get((int) info.id));
        Context context = getView().getContext();
        CharSequence text = getResources().getString(R.string.songsViewSongAdded);
        int duration = Toast.LENGTH_SHORT;
        Toast toast = Toast.makeText(context, text, duration);
        toast.show();//from   w  ww.  j  ava 2s  .  c  o m
        return true;
    case R.id.contextMenuSongsOpen:
        controller.getPlayNow().clear();
        controller.getPlayNow().add(controller.getSongs().get((int) info.id));
        ((MainActivity) getActivity()).play(0);
        return true;
    default:
        return super.onContextItemSelected(item);
    }
}

From source file:de.androvdr.fragments.EpgsdataFragment.java

@Override
public boolean onContextItemSelected(MenuItem item) {
    AdapterContextMenuInfo info = (AdapterContextMenuInfo) item.getMenuInfo();
    switch (item.getItemId()) {
    case R.id.epgs_record:
        mController.action(EpgsdataController.EPGSDATA_ACTION_RECORD, info.position);
        return true;
    }/*from  w w w  .ja v  a2  s  .  co m*/
    return false;
}

From source file:id.nci.stm_9.KeyListSecretFragment.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);

    // get master key id using row id
    long masterKeyId = ProviderHelper.getSecretMasterKeyId(mKeyListSecretActivity, keyRingRowId);

    boolean masterCanSign = ProviderHelper.getSecretMasterKeyCanSign(mKeyListSecretActivity, keyRingRowId);

    switch (item.getItemId()) {
    case 0x21070003:
        mKeyListSecretActivity.editKey(masterKeyId, masterCanSign);

        return true;

    default:/*from   www .j  ava  2  s  . c om*/
        return super.onContextItemSelected(item);

    }
}

From source file:test.red.house.DeviceFragment.java

@Override
public boolean onContextItemSelected(android.view.MenuItem item) {
    AdapterView.AdapterContextMenuInfo info = (AdapterView.AdapterContextMenuInfo) item.getMenuInfo();
    Log.d("DeviceFragment", "item = " + item + ", getGroupId() = " + item.getGroupId());
    if (item.getGroupId() == 0) {
        switch (item.getOrder()) {
        case 0:/* w  ww  . ja va 2 s .c o  m*/
            Log.d("DeviceFragment", "item.getOrder() = 0");

            Cursor c = (Cursor) getListAdapter().getItem(info.position);

            Log.d("DeviceFragment", "Device OPTION1 remove object: " + c.getInt(0));
            MainActivity.db.removeDevice(c.getInt(0));
            c.close();
            Cursor c1 = MainActivity.db.getDevices();
            DeviceFragment.adapter.changeCursor(c1);
            return true;
        case 1:
            return true;
        default:
        }
        return super.onContextItemSelected(item);
    } else if (item.getGroupId() == 1) {
        switch (item.getOrder()) {
        case 0:
            Log.d("DeviceFragment", "P");

            //                 Cursor c = (Cursor) getListAdapter().getItem(info.position);
            Cursor c = (Cursor) SensorFragment.adapter.getItem(info.position);

            Log.d("DeviceFragment", "Sensor OPTION1 remove object:" + c.getInt(0));
            MainActivity.db.removeSensor(c.getInt(0));
            c.close();
            Cursor c1 = MainActivity.db.getSensors();
            SensorFragment.adapter.changeCursor(c1);
            return true;
        case 1:
            return true;
        default:
        }
        return super.onContextItemSelected(item);
    } else {
        return true;
    }
}

From source file:com.makotosan.vimeodroid.ManageTransfersActivity.java

@Override
public boolean onContextItemSelected(MenuItem item) {
    AdapterContextMenuInfo info = (AdapterContextMenuInfo) item.getMenuInfo();
    if (item.getItemId() == R.id.contextmenu_cancel) {
        Transfer transfer = getModel(info.position);
        AbortableHttpRequest request = transfer.getAbortableRequest();
        if (request != null) {
            request.abort();/*  w  ww .  j av  a  2s  .co  m*/
        }
    }

    return true;
}

From source file:com.racoon.ampdroid.views.AlbumsView.java

@Override
public boolean onContextItemSelected(MenuItem item) {
    AdapterContextMenuInfo info = (AdapterContextMenuInfo) item.getMenuInfo();
    Album a = controller.getAlbums().get((int) info.id);
    switch (item.getItemId()) {
    case R.id.contextMenuAdd:
        for (Song s : controller.findSongs(a)) {
            controller.getPlayNow().add(s);
        }//from  www  .  j a  v a2  s  . c  om
        Context context = getView().getContext();
        CharSequence text = getResources().getString(R.string.albumsViewAlbumsAdded);
        int duration = Toast.LENGTH_SHORT;
        Toast toast = Toast.makeText(context, text, duration);
        toast.show();
        return true;
    case R.id.contextMenuOpen:
        controller.getSelectedSongs().clear();
        for (Song s : controller.findSongs(a)) {
            controller.getSelectedSongs().add(s);
        }
        // Create new fragment and transaction
        SelectedSongsView newFragment = new SelectedSongsView();
        FragmentTransaction transaction = getActivity().getSupportFragmentManager().beginTransaction();

        // Replace whatever is in the fragment_container view with this fragment,
        // and add the transaction to the back stack
        transaction.replace(R.id.content_frame, newFragment);
        transaction.addToBackStack(null);

        // Commit the transaction
        transaction.commit();
        return true;
    default:
        return super.onContextItemSelected(item);
    }
}

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

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

    switch (item.getItemId()) {
    case R.id.ctx_menu_show_phonebook_contact:
        final Contact contact = getListAdapter().getItem(info.position);

        if (listener != null)
            listener.onShowPhoneBookEntryOfContact(contact.getLookUpKey());

        return true;

    default:/*from   w  ww  .  jav a 2  s.  co  m*/
        return super.onContextItemSelected(item);
    }
}

From source file:org.sufficientlysecure.keychain.ui.KeyListSecretFragment.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);

    // get master key id using row id
    long masterKeyId = ProviderHelper.getSecretMasterKeyId(mKeyListSecretActivity, keyRingRowId);

    boolean masterCanSign = ProviderHelper.getSecretMasterKeyCanSign(mKeyListSecretActivity, keyRingRowId);

    switch (item.getItemId()) {
    case Id.menu.edit:
        mKeyListSecretActivity.checkPassPhraseAndEdit(masterKeyId, masterCanSign);

        return true;

    default://from   www .  j ava  2s  .c  o  m
        return super.onContextItemSelected(item);

    }
}

From source file:org.totschnig.myexpenses.activity.ManageAccounts.java

@Override
public boolean onContextItemSelected(android.view.MenuItem item) {
    AdapterContextMenuInfo info = (AdapterContextMenuInfo) item.getMenuInfo();
    switch (item.getItemId()) {
    case R.id.DELETE_COMMAND:
        MessageDialogFragment/*from   ww w . j  av a 2  s .  c o  m*/
                .newInstance(R.string.dialog_title_warning_delete_account, R.string.warning_delete_account,
                        new MessageDialogFragment.Button(android.R.string.yes, R.id.DELETE_COMMAND_DO, info.id),
                        null, MessageDialogFragment.Button.noButton())
                .show(getSupportFragmentManager(), "DELETE_ACCOUNT");
        return true;
    case R.id.RESET_ACCOUNT_COMMAND:
        DialogUtils.showWarningResetDialog(this, info.id);
        return true;
    case R.id.EDIT_ACCOUNT_COMMAND:
        Intent i = new Intent(this, AccountEdit.class);
        i.putExtra(KEY_ROWID, info.id);
        startActivityForResult(i, 0);
        return true;
    }
    return super.onContextItemSelected(item);
}