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.totschnig.myexpenses.activity.ManageMethods.java

@Override
public boolean onContextItemSelected(android.view.MenuItem item) {
    AdapterContextMenuInfo info = (AdapterContextMenuInfo) item.getMenuInfo();
    switch (item.getItemId()) {
    case R.id.DELETE_COMMAND:
        if (Transaction.countPerMethod(info.id) > 0) {
            Toast.makeText(this, getString(R.string.not_deletable_mapped_transactions), Toast.LENGTH_LONG)
                    .show();//from   www .j  a  v a 2 s  .  c  o m
        } else if (Template.countPerMethod(info.id) > 0) {
            Toast.makeText(this, getString(R.string.not_deletable_mapped_templates), Toast.LENGTH_LONG).show();
        } else {
            FragmentManager fm = getSupportFragmentManager();
            fm.beginTransaction().add(TaskExecutionFragment
                    .newInstance(TaskExecutionFragment.TASK_DELETE_PAYMENT_METHOD, info.id, null), "ASYNC_TASK")
                    .commit();
        }
        return true;
    }
    return super.onContextItemSelected(item);
}

From source file:net.meiolania.apps.habrahabr.fragments.qa.QaCommentsFragment.java

@Override
public boolean onContextItemSelected(MenuItem item) {
    AdapterContextMenuInfo adapterContextMenuInfo = (AdapterContextMenuInfo) item.getMenuInfo();
    CommentsData commentsData = (CommentsData) getListAdapter().getItem(adapterContextMenuInfo.position);

    switch (item.getItemId()) {
    case MENU_OPEN_COMMENT_IN_BROWSER:
        startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse(commentsData.getUrl())));
        break;//from  w  w w.jav a2s  . com
    case MENU_OPEN_AUTHOR_PROFILE:
        startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse(commentsData.getAuthorUrl())));
        break;
    }
    return super.onContextItemSelected(item);
}

From source file:net.meiolania.apps.habrahabr.fragments.posts.PostsCommentsFragment.java

@Override
public boolean onContextItemSelected(MenuItem item) {
    AdapterContextMenuInfo adapterContextMenuInfo = (AdapterContextMenuInfo) item.getMenuInfo();
    CommentsData commentsData = (CommentsData) getListAdapter().getItem(adapterContextMenuInfo.position);

    switch (item.getItemId()) {
    case MENU_OPEN_COMMENT_IN_BROWSER:
        startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse(commentsData.getUrl())));
        break;/*from ww  w  .j av a 2  s .c  o  m*/
    case MENU_OPEN_AUTHOR_PROFILE:
        startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse(commentsData.getAuthorUrl())));
        break;
    }

    return super.onContextItemSelected(item);
}

From source file:com.softminds.matrixcalculator.base_fragments.MainActivityFragmentList.java

@Override
public boolean onContextItemSelected(MenuItem item) {
    AdapterView.AdapterContextMenuInfo info = (AdapterView.AdapterContextMenuInfo) item.getMenuInfo();
    switch (item.getItemId()) {
    case R.id.QuickDelete:
        ((GlobalValues) getActivity().getApplication()).GetCompleteList().remove(info.position);
        ((GlobalValues) getActivity().getApplication()).matrixAdapter.notifyDataSetChanged();
        Toast.makeText(getContext(), R.string.Deleted, Toast.LENGTH_SHORT).show();
        break;//from   w  w  w  . ja  v a  2  s  .  c o  m
    case R.id.QuickRename:
        position1 = info.position;
        Intent rename = new Intent(getContext(), RenameCreated.class);
        rename.putExtra("TITLE_OF_THIS_FORMATION",
                ((GlobalValues) getActivity().getApplication()).GetCompleteList().get(info.position).getName());
        startActivityForResult(rename, 100);
        break;
    case R.id.QuickChange:
        Intent order = new Intent(getContext(), OrderChanger.class);
        order.putExtra("INDEX_OF_SELECTED_MATRIX", info.position);
        startActivityForResult(order, 12);

    }
    return super.onContextItemSelected(item);
}

From source file:net.potterpcs.recipebook.TagsEditor.java

@Override
public boolean onContextItemSelected(MenuItem item) {
    AdapterContextMenuInfo info = (AdapterContextMenuInfo) item.getMenuInfo();
    switch (item.getItemId()) {
    case R.id.ctxdeletetag:
        adapter.remove(adapter.getItem(info.position));
        return true;

    case R.id.ctxedittag:
        ((EditText) getView().findViewById(R.id.tagsedit)).setText(adapter.getItem(info.position));
        adapter.remove(adapter.getItem(info.position));
        return true;

    default://  ww  w.j  a va 2s.  c  o m
        return super.onContextItemSelected(item);
    }
}

From source file:org.getlantern.firetweet.util.ThemeUtils.java

public static void applyColorFilterToMenuIcon(final Menu menu, final int color, final int popupColor,
        final int highlightColor, final Mode mode, final int... excludedGroups) {
    for (int i = 0, j = menu.size(); i < j; i++) {
        final MenuItem item = menu.getItem(i);
        final Drawable icon = item.getIcon();
        final ContextMenuInfo info = item.getMenuInfo();
        if (icon != null && !ArrayUtils.contains(excludedGroups, item.getGroupId())) {
            icon.mutate();// w w w.  j a  v  a  2 s  .  co m
            if (info instanceof FiretweetMenuInfo) {
                final FiretweetMenuInfo sInfo = (FiretweetMenuInfo) info;
                icon.setColorFilter(sInfo.isHighlight() ? sInfo.getHighlightColor(highlightColor) : color,
                        mode);
            } else {
                icon.setColorFilter(color, mode);
            }
        }
        if (item.hasSubMenu()) {
            // SubMenu item is always in popup
            applyColorFilterToMenuIcon(item.getSubMenu(), popupColor, popupColor, highlightColor, mode,
                    excludedGroups);
        }
    }
}

From source file:com.arconus.dicecommander.ui.fragment.PowerCardGridFragment.java

@Override
public boolean onContextItemSelected(MenuItem item) {
    AdapterContextMenuInfo info = (AdapterContextMenuInfo) item.getMenuInfo();
    switch (item.getItemId()) {
    case R.id.power_card_list_item_menu_clone:
        CharPower clonePower = GameCharacterManager.getInstance().getPowerFromSelectedChar(info.position);
        Intent cloneIntent = new Intent(getActivity(), PowerWizardActivity.class);
        cloneIntent.putExtra(PowerWizardActivity.EDIT_POWER_ID, -1);
        cloneIntent.putExtra(PowerWizardActivity.EDIT_POWER_MODEL,
                new PowerWizardBundler(clonePower).createBundleFromPower());
        startActivity(cloneIntent);/*from  ww  w  .  ja v a  2  s .c  om*/
        return true;

    case R.id.power_card_list_item_menu_edit:
        CharPower editPower = GameCharacterManager.getInstance().getPowerFromSelectedChar(info.position);
        Intent editIntent = new Intent(getActivity(), PowerWizardActivity.class);
        editIntent.putExtra(PowerWizardActivity.EDIT_POWER_ID, info.position);
        editIntent.putExtra(PowerWizardActivity.EDIT_POWER_MODEL,
                new PowerWizardBundler(editPower).createBundleFromPower());
        startActivity(editIntent);
        return true;

    case R.id.power_card_list_item_menu_remove:
        GameCharacterManager.getInstance().deleteCharPowerFromSelectedCharacter(info.position);
        refreshAdapter();
        return true;
    default:
        return super.onContextItemSelected(item);
    }
}

From source file:can.yrt.onebusaway.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 = UIHelp.makeShortcut(getActivity(), stopData.uiName,
                stopData.getArrivalsList().getIntent());
        shortcutIntent.setAction(MyListConstants.INSTALL_SHORTCUT);
        shortcutIntent.setFlags(0);/*from   w  w w  . j a va2  s .c  om*/
        getActivity().sendBroadcast(shortcutIntent);
        return true;
    default:
        return super.onContextItemSelected(item);
    }
}

From source file:org.gateshipone.odyssey.fragments.AlbumsFragment.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  .j  a v a  2s.  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_albums_action_enqueue:
        enqueueAlbum(info.position);
        return true;
    case R.id.fragment_albums_action_play:
        playAlbum(info.position);
        return true;
    case R.id.fragment_albums_action_showartist:
        showArtist(info.position);
        return true;
    default:
        return super.onContextItemSelected(item);
    }
}

From source file:com.zoterodroid.activity.BrowseCitations.java

@Override
public boolean onContextItemSelected(MenuItem aItem) {
    AdapterContextMenuInfo menuInfo = (AdapterContextMenuInfo) aItem.getMenuInfo();
    final Citation b = (Citation) lv.getItemAtPosition(menuInfo.position);

    switch (aItem.getItemId()) {
    case 0:/*  www  . ja  v  a 2 s. c  om*/
        return true;

    case 1:
        return true;
    }
    return false;
}