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:com.akop.bach.fragment.playstation.TrophiesFragment.java

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

    if (mGameTitle != null && info.targetView.getTag() instanceof ViewHolder) {
        ViewHolder vh = (ViewHolder) info.targetView.getTag();

        switch (menuItem.getItemId()) {
        case R.id.menu_google_trophies:
            Intent searchIntent = new Intent(Intent.ACTION_WEB_SEARCH);
            searchIntent.putExtra(SearchManager.QUERY,
                    getString(R.string.google_trophy_f, mGameTitle, vh.title.getText()));

            startActivity(searchIntent);
            return true;
        }//from  w ww  .ja v  a  2 s .  c om
    }

    return super.onContextItemSelected(menuItem);
}

From source file:org.videolan.vlc.gui.browser.BaseBrowserFragment.java

@Override
public boolean onContextItemSelected(MenuItem item) {
    ContextMenuRecyclerView.RecyclerContextMenuInfo info = (ContextMenuRecyclerView.RecyclerContextMenuInfo) item
            .getMenuInfo();/*from ww  w  .  j a  v a  2s . co m*/
    if (info != null && handleContextItemSelected(item, info.position))
        return true;
    return super.onContextItemSelected(item);
}

From source file:com.cachirulop.moneybox.fragment.MovementsFragment.java

/**
 * Handles the selected item on the context menu. Could be an option to
 * delete the item or to get it from the moneybox.
 *///  www  .  j  av  a  2s.c om
@Override
public boolean onContextItemSelected(MenuItem item) {
    int itemId;

    itemId = item.getItemId();
    if (itemId == CONTEXT_MENU_GET || itemId == CONTEXT_MENU_DELETE || itemId == CONTEXT_MENU_DROP) {

        AdapterView.AdapterContextMenuInfo info;
        ListView listView;
        Movement selected;

        listView = (ListView) getActivity().findViewById(R.id.lvMovements);
        info = (AdapterView.AdapterContextMenuInfo) item.getMenuInfo();

        selected = (Movement) ((MoneyboxMovementAdapter) listView.getAdapter()).getItem(info.position);

        switch (itemId) {
        case CONTEXT_MENU_GET:
            MovementsManager.getMovement(selected);
            ((IMoneyboxListener) getActivity()).onGetMovement(selected);
            break;

        case CONTEXT_MENU_DROP:
            MovementsManager.dropMovement(selected);
            break;

        case CONTEXT_MENU_DELETE:
            MovementsManager.deleteMovement(selected);
            ((IMoneyboxListener) getActivity()).onDeleteMovement(selected);
            break;
        }

        refresh();
    }

    return true;
}

From source file:com.orange.ocara.ui.activity.SetupAuditPathActivity.java

@Override
public boolean onContextItemSelected(MenuItem item) {

    AdapterView.AdapterContextMenuInfo info = (AdapterView.AdapterContextMenuInfo) item.getMenuInfo();
    final AuditObject auditObject = auditObjectsAdapter.getItem(info.position);

    int i = item.getItemId();
    if (i == com.orange.ocara.R.id.action_object_update) {
        updateAuditObject(auditObject);//ww w  . j a  va2 s .  c o  m
        return true;
    } else if (i == com.orange.ocara.R.id.action_object_comment) {
        commentAuditObject(auditObject);
        return true;
    } else if (i == com.orange.ocara.R.id.action_object_characteristics) {
        SelectAuditObjectCharacteristicsDialogBuilder.showCharacteriscticsAuditObject(this, auditObject, this);
        return true;
    } else if (i == com.orange.ocara.R.id.action_object_detail) {
        showDetailsObject(auditObject);
        return true;
    } else if (i == com.orange.ocara.R.id.action_object_remove) {
        askToDeleteAuditObject(auditObject);
        return true;
    } else {
        return super.onContextItemSelected(item);
    }

}

From source file:edu.mit.mobile.android.locast.ver2.itineraries.ItineraryDetail.java

@Override
public boolean onContextItemSelected(MenuItem item) {
    AdapterView.AdapterContextMenuInfo info;
    try {/*from   www .  ja  v a2 s .co  m*/
        info = (AdapterView.AdapterContextMenuInfo) item.getMenuInfo();
    } catch (final ClassCastException e) {
        Log.e(TAG, "bad menuInfo", e);
        return false;
    }

    final Uri cast = Cast.getCanonicalUri(this, ContentUris.withAppendedId(mCastsUri, info.id));

    switch (item.getItemId()) {
    case R.id.cast_view:
        startActivity(new Intent(Intent.ACTION_VIEW, cast));
        return true;

    case R.id.cast_edit:
        startActivity(new Intent(Intent.ACTION_EDIT, cast));
        return true;

    case R.id.cast_delete:
        startActivity(new Intent(Intent.ACTION_DELETE, cast));
        return true;

    //       case R.id.cast_play:
    //          startActivity(new Intent(CastDetailsActivity.ACTION_PLAY_CAST, cast));
    //          return true;

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

From source file:de.electricdynamite.pasty.ClipboardFragment.java

@SuppressLint("NewApi")
public boolean onContextItemSelected(android.view.MenuItem item) {
    AdapterView.AdapterContextMenuInfo info = (AdapterView.AdapterContextMenuInfo) item.getMenuInfo();
    int menuItemIndex = item.getItemId();
    ClipboardItem Item = mItems.get(info.position);
    switch (menuItemIndex) {
    case PastySharedStatics.ITEM_CONTEXTMENU_COPY_ID:
        // Copy without exit selected
        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) {
            android.content.ClipboardManager clipboard = (android.content.ClipboardManager) getSherlockActivity()
                    .getSystemService(Context.CLIPBOARD_SERVICE);
            Item.copyToClipboard(clipboard);
            clipboard = null;/*from   w  ww  .ja v a2  s. com*/
        } else {
            ClipboardManager clipboard = (ClipboardManager) getSherlockActivity()
                    .getSystemService(Context.CLIPBOARD_SERVICE);
            Item.copyToClipboard(clipboard);
            clipboard = null;
        }
        Toast.makeText(getSherlockActivity().getApplicationContext(), getString(R.string.item_copied),
                Toast.LENGTH_LONG).show();

        break;
    case PastySharedStatics.ITEM_CONTEXTMENU_SHARE_ID:
        // Share to another app
        Intent shareIntent = new Intent(android.content.Intent.ACTION_SEND);
        shareIntent.setType("text/plain");
        shareIntent.putExtra(android.content.Intent.EXTRA_TEXT, Item.getText());
        startActivity(Intent.createChooser(shareIntent, getString(R.string.app_share_from_pasty)));
        break;
    case PastySharedStatics.ITEM_CONTEXTMENU_DELETE_ID:
        // Delete selected
        mAdapter.delete(info.position);
        break;
    case PastySharedStatics.ITEM_CONTEXTMENU_OPEN_ID:
        /* If the clicked item was originally linkified, we
        * fire an ACTION_VIEW intent.
        */
        String url = Item.getText();
        if (!URLUtil.isValidUrl(url))
            url = "http://" + url;
        Intent i = new Intent(Intent.ACTION_VIEW);
        i.setData(Uri.parse(url));
        startActivity(i);
        break;
    }
    return true;
}

From source file:net.gerosyab.dailylog.activity.MainActivity.java

@Override
public boolean onContextItemSelected(MenuItem item) {
    AdapterView.AdapterContextMenuInfo info = (AdapterView.AdapterContextMenuInfo) item.getMenuInfo();
    MyLog.d(LOG_TAG, "onContextItemSelected() - item : " + item.toString());
    switch (item.getItemId()) {
    case R.id.action_edit:
        editCategory(info.id);/*from ww w. j a va2 s.  c  o m*/
        return true;
    case R.id.action_delete:
        deleteCategory(info.id);
        return true;
    case R.id.action_export:
        exportCategory(info.id);
        return true;
    default:
        return super.onContextItemSelected(item);
    }

}

From source file:il.ac.shenkar.todos.view.MainActivity.java

@Override
public boolean onContextItemSelected(MenuItem menuItem) {
    ExpandableListContextMenuInfo info = (ExpandableListContextMenuInfo) menuItem.getMenuInfo();
    // holds current item position
    int index = ExpandableListView.getPackedPositionGroup(info.packedPosition);
    currentPosition = index;/*from  ww w  .  ja  v  a2s .co m*/

    // determines which item was selected at the menu
    switch (menuItem.getItemId()) {
    case R.id.editTitle:
        alertDialog = new AlertDialogs();
        alertDialog.setArguments(getArguments(Utils.DIALOG_TEXT_ENTRY, index, Utils.EDIT_TITLE));
        alertDialog.show(getFragmentManager(), "ShowAlertDialog");
        return true;

    case R.id.editDescription:
        alertDialog = new AlertDialogs();
        alertDialog.setArguments(getArguments(Utils.DIALOG_LONG_TEXT_ENTRY, index, Utils.EDIT_DESCRIPTION));
        alertDialog.show(getFragmentManager(), "ShowAlertDialog");
        return true;

    case R.id.markImportant:
        // mark the task as important/unimportant
        boolean important = taskListModel.getTaskAt(index).isImportant();
        taskListModel.getTaskAt(index).setImportant(!important);
        taskListModel.getDataBase().updateTask(taskListModel.getTaskAt(index));
        adapter.notifyDataSetChanged();
        return true;

    case R.id.deleteTask:
        taskToUndo = taskListModel.getTaskAt(index);
        taskListModel.removeTask(index);
        mediaPlayer.playAudio(Utils.DELETE_SOUND);
        taskAlarms.disableTaskAlerts(taskToUndo);
        adapter.notifyDataSetChanged();
        showUndo(viewContainer);
        return true;

    case R.id.setLocation:
        alertDialog = new AlertDialogs();
        alertDialog.setArguments(getArguments(Utils.DIALOG_TEXT_ENTRY, index, Utils.SET_LOCATION));
        alertDialog.show(getFragmentManager(), "ShowAlertDialog");
        return true;

    case R.id.share:
        shareTask(index);

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

From source file:com.afg.MngProductContentProvider.Fragments.ListCategory_Fragment.java

@Override
public boolean onContextItemSelected(final MenuItem item) {

    AlertDialog.Builder alertDialog = new AlertDialog.Builder(getContext());

    alertDialog.setTitle("Aviso");
    alertDialog.setMessage("Esta seguro que desea borrar esta farmacia?");

    alertDialog.setPositiveButton("Borrar", new DialogInterface.OnClickListener() {
        @Override//ww  w.j a va2  s .  co m
        public void onClick(DialogInterface dialogInterface, int i) {

            presenter.deleteCategory((Category) adapter
                    .getItem(((AdapterView.AdapterContextMenuInfo) item.getMenuInfo()).position));

        }
    }).setNegativeButton("Cancelar", new DialogInterface.OnClickListener() {
        @Override
        public void onClick(DialogInterface dialogInterface, int i) {

        }
    }).show();

    return super.onContextItemSelected(item);
}

From source file:com.audiokernel.euphonyrmt.SearchActivity.java

@Override
public boolean onMenuItemClick(final MenuItem item) {
    final AdapterContextMenuInfo info = (AdapterContextMenuInfo) item.getMenuInfo();
    final List<? extends Item> targetArray;
    switch (mPager.getCurrentItem()) {
    case 1:/*from   ww  w  .ja va 2s .c o  m*/
        targetArray = mAlbumResults;
        break;
    case 2:
        targetArray = mSongResults;
        break;
    case 0:
    default:
        targetArray = mArtistResults;
        break;
    }
    final Object selectedItem = targetArray.get((int) info.id);
    if (item.getItemId() == GOTO_ALBUM) {
        if (selectedItem instanceof Music) {
            final Music music = (Music) selectedItem;
            final Intent intent = new Intent(this, SimpleLibraryActivity.class);
            final Parcelable artist = new Artist(music.getAlbumArtistOrArtist());
            intent.putExtra("artist", artist);
            intent.putExtra("album", music.getAlbumAsAlbum());
            startActivityForResult(intent, -1);
        }
    } else {
        mApp.oMPDAsyncHelper.execAsync(new Runnable() {
            @Override
            public void run() {
                boolean replace = false;
                boolean play = false;
                switch (item.getItemId()) {
                case ADD_REPLACE_PLAY:
                    replace = true;
                    play = true;
                    break;
                case ADD_REPLACE:
                    replace = true;
                    break;
                case ADD_PLAY:
                    play = true;
                    break;
                default:
                    break;
                }
                add(selectedItem, replace, play);
            }
        });
    }
    return false;
}