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.sxt.superqq.fragment.ContactlistFragment.java

@Override
public boolean onContextItemSelected(MenuItem item) {
    if (item.getItemId() == R.id.delete_contact) {
        UserBean tobeDeleteUser = mAdapter.getItem(((AdapterContextMenuInfo) item.getMenuInfo()).position);
        // ?/*w ww . ja v  a2s  .  c  om*/
        deleteContact(tobeDeleteUser);
        // ?
        InviteMessgeDao dao = new InviteMessgeDao(getActivity());
        dao.deleteMessage(tobeDeleteUser.getUserName());
        return true;
    } else if (item.getItemId() == R.id.add_to_blacklist) {
        UserBean user = mAdapter.getItem(((AdapterContextMenuInfo) item.getMenuInfo()).position);
        moveToBlacklist(user.getUserName());
        return true;
    }
    return super.onContextItemSelected(item);
}

From source file:com.chess.genesis.activity.GameListLocalFrag.java

@Override
public boolean onContextItemSelected(final MenuItem item) {
    if (!act.lastContextMenu.equals(getBTag()))
        return super.onContextItemSelected(item);

    switch (item.getItemId()) {
    case R.id.new_game:
    case R.id.import_game:
        return onOptionsItemSelected(item);
    }//from   w ww.  j a  v a2  s.c o m

    final AdapterContextMenuInfo info = (AdapterContextMenuInfo) item.getMenuInfo();
    final Bundle bundle = (Bundle) gamelist_adapter.getItem((int) info.id);

    switch (item.getItemId()) {
    case R.id.delete_game:
        new DeleteLocalDialog(act, handle, Integer.parseInt(bundle.getString("id"))).show();
        break;
    case R.id.rename_game:
        new RenameGameDialog(act, handle, Integer.parseInt(bundle.getString("id")), bundle.getString("name"))
                .show();
        break;
    case R.id.share_game:
        sendGame(bundle);
        break;
    default:
        return super.onContextItemSelected(item);
    }
    return true;
}

From source file:com.googlecode.android_scripting.activity.ApiBrowser.java

@Override
public boolean onContextItemSelected(MenuItem item) {
    AdapterView.AdapterContextMenuInfo info;
    try {//w  ww  .j  a  v  a  2 s  .  c  o m
        info = (AdapterView.AdapterContextMenuInfo) item.getMenuInfo();
    } catch (ClassCastException e) {
        Log.e("Bad menuInfo", e);
        return false;
    }

    MethodDescriptor rpc = (MethodDescriptor) ((ApiItem) pList.getAdapter().getItem(info.position)).getMethod();
    if (rpc == null) {
        Log.v("No RPC selected.");
        return false;
    }

    if (item.getItemId() == ContextMenuId.INSERT_TEXT.getId()) {
        // There's no activity to track calls to insert (like there is for
        // prompt) so we track it
        // here instead.
        Analytics.track("ApiInsert");
        insertText(rpc, new String[0]);
    } else if (item.getItemId() == ContextMenuId.PROMPT_PARAMETERS.getId()) {
        Intent intent = new Intent(this, ApiPrompt.class);
        intent.putExtra(Constants.EXTRA_API_PROMPT_RPC_NAME, rpc.getName());
        ParameterDescriptor[] parameters = rpc.getParameterValues(new String[0]);
        String[] values = new String[parameters.length];
        int index = 0;
        for (ParameterDescriptor parameter : parameters) {
            values[index++] = parameter.getValue();
        }
        intent.putExtra(Constants.EXTRA_API_PROMPT_VALUES, values);
        startActivityForResult(intent, RequestCode.RPC_PROMPT.ordinal());
    } else if (item.getItemId() == ContextMenuId.HELP.getId()) {
        String help = rpc.getDeclaringClass().getSimpleName() + ".html#" + rpc.getName();
        Help.showApiHelp(this, help);

    }
    return true;
}

From source file:com.truman.showtime.showtime.ui.fragment.MovieListFragment.java

@Override
public boolean onContextItemSelected(MenuItem item) {
    if (item.getTitle().equals(getString(R.string.share_movie))) {
        AdapterViewCompat.AdapterContextMenuInfo info = (AdapterViewCompat.AdapterContextMenuInfo) item
                .getMenuInfo();/*from w  ww  .j a v a 2 s  .  c o  m*/
        Intent sendIntent = new Intent();
        sendIntent.setAction(Intent.ACTION_SEND);
        sendIntent.putExtra(Intent.EXTRA_TEXT, mSelectedMovie.name + "\n" + "http://google.com/movies?near="
                + mCity + "&mid=" + mSelectedMovie.id);
        sendIntent.setType("text/plain");
        startActivity(Intent.createChooser(sendIntent, getResources().getString(R.string.share_movie)));
    }
    return super.onContextItemSelected(item);
}

From source file:net.gaast.giggity.ChooserActivity.java

@Override
public boolean onContextItemSelected(MenuItem item) {
    AdapterContextMenuInfo mi = (AdapterContextMenuInfo) item.getMenuInfo();
    Giggity app = (Giggity) getApplication();
    DbSchedule sched = (DbSchedule) lista.getItem((int) mi.id);
    if (sched == null) {
    } else if (item.getItemId() == 0) {
        /* Refresh. */
        app.flushSchedule(sched.getUrl());
        openSchedule(sched, true);//  w  w w .j  av  a2s  .co m
    } else if (item.getItemId() == 3) {
        /* Unhide. */
        sched.flushHidden();
        /* Refresh. */
        app.flushSchedule(sched.getUrl());
        openSchedule(sched, false);
    } else if (item.getItemId() == 1) {
        /* Delete. */
        db.removeSchedule(sched.getUrl());
        onResume();
    } else {
        /* Show URL; try a QR code but fall back to a dialog if the app is not installed. */
        try {
            Intent intent = new Intent(BARCODE_ENCODE);
            intent.putExtra("ENCODE_TYPE", "TEXT_TYPE");
            intent.putExtra("ENCODE_DATA", sched.getUrl());
            startActivity(intent);
        } catch (ActivityNotFoundException e) {
            new AlertDialog.Builder(ChooserActivity.this).setTitle(sched.getTitle()).setMessage(sched.getUrl())
                    .show();
        }
    }
    return false;
}

From source file:org.videolan.vlc2.gui.audio.AudioBrowserFragment.java

private boolean handleContextItemSelected(MenuItem item, int position) {
    ContextMenuInfo menuInfo = item.getMenuInfo();

    int startPosition;
    int groupPosition;
    List<String> medias;
    int id = item.getItemId();

    boolean useAllItems = id == R.id.audio_list_browser_play_all;
    boolean append = id == R.id.audio_list_browser_append;

    if (ExpandableListContextMenuInfo.class.isInstance(menuInfo)) {
        ExpandableListContextMenuInfo info = (ExpandableListContextMenuInfo) menuInfo;
        groupPosition = ExpandableListView.getPackedPositionGroup(info.packedPosition);
    } else//  w w  w .  j  av a2s . co m
        groupPosition = position;

    if (id == R.id.audio_list_browser_delete) {
        AlertDialog alertDialog = CommonDialogs.deleteMedia(getActivity(),
                mSongsAdapter.getLocations(groupPosition).get(0),
                new VLCRunnable(mSongsAdapter.getItem(groupPosition)) {
                    @Override
                    public void run(Object o) {
                        AudioBrowserListAdapter.ListItem listItem = (AudioBrowserListAdapter.ListItem) o;
                        Media media = listItem.mMediaList.get(0);
                        mMediaLibrary.getMediaItems().remove(media);
                        mAudioController.removeLocation(media.getLocation());
                        updateLists();
                    }
                });
        alertDialog.show();
        return true;
    }

    if (id == R.id.audio_list_browser_set_song) {
        AudioUtil.setRingtone(mSongsAdapter.getItem(groupPosition).mMediaList.get(0), getActivity());
        return true;
    }

    if (useAllItems) {
        medias = new ArrayList<String>();
        startPosition = mSongsAdapter.getListWithPosition(medias, groupPosition);
    } else {
        startPosition = 0;
        switch (mFlingViewGroup.getPosition()) {
        case MODE_SONG:
            medias = mSongsAdapter.getLocations(groupPosition);
            break;
        case MODE_ARTIST:
            medias = mArtistsAdapter.getLocations(groupPosition);
            break;
        case MODE_ALBUM:
            medias = mAlbumsAdapter.getLocations(groupPosition);
            break;
        case MODE_GENRE:
            medias = mGenresAdapter.getLocations(groupPosition);
            break;
        default:
            return true;
        }
    }

    if (append)
        mAudioController.append(medias);
    else
        mAudioController.load(medias, startPosition);

    return super.onContextItemSelected(item);
}

From source file:com.ninetwozero.battlelog.ForumActivity.java

@Override
public boolean onContextItemSelected(MenuItem item) {

    // Declare...
    AdapterView.AdapterContextMenuInfo info;

    // Let's try to get some menu information via a try/catch
    try {//from   w ww  . j  av a 2  s  . c  om

        info = (AdapterView.AdapterContextMenuInfo) item.getMenuInfo();

    } catch (ClassCastException e) {

        e.printStackTrace();
        return false;

    }

    switch (viewPager.getCurrentItem()) {

    case 2:
        return fragmentForumThread.handleSelectedContextItem(info, item);

    default:
        break;

    }

    return true;

}

From source file:org.geometerplus.android.fbreader.network.NetworkLibraryActivity.java

@Override
public boolean onContextItemSelected(MenuItem item) {
    final int position = ((AdapterView.AdapterContextMenuInfo) item.getMenuInfo()).position;
    final NetworkTree tree = (NetworkTree) getListAdapter().getItem(position);
    if (tree != null) {
        for (Action a : getContextMenuActions(tree)) {
            if (a.Code == item.getItemId()) {
                checkAndRun(a, tree);/*from w  w  w.  j av  a 2  s  . c o  m*/
                return true;
            }
        }
    }
    return super.onContextItemSelected(item);
}

From source file:com.imalu.alyou.activity.FriendlistFragment.java

@Override
public boolean onContextItemSelected(MenuItem item) {
    if (item.getItemId() == R.id.delete_contact) {
        Friend tobeDeleteUser = adapter.getItem(((AdapterContextMenuInfo) item.getMenuInfo()).position);
        // ?/*www  .  j a  v  a2  s.com*/
        //         deleteContact(tobeDeleteUser);
        // ?
        //         InviteMessgeDao dao = new InviteMessgeDao(getActivity());
        //         dao.deleteMessage(tobeDeleteUser.getUsername());
        return true;
    } else if (item.getItemId() == R.id.add_to_blacklist) {
        Friend user = adapter.getItem(((AdapterContextMenuInfo) item.getMenuInfo()).position);
        //         moveToBlacklist(user.getUsername());
        return true;
    }
    return super.onContextItemSelected(item);
}

From source file:org.flerda.android.honeypad.NoteListFragment.java

@Override
public boolean onContextItemSelected(MenuItem item) {
    switch (item.getItemId()) {
    case DELETE_ID:
        AdapterContextMenuInfo info = (AdapterContextMenuInfo) item.getMenuInfo();
        getListView().setItemChecked(info.position, false);
        getActivity().getContentResolver()
                .delete(ContentUris.withAppendedId(NotesProvider.CONTENT_URI, info.id), null, null);
        // clear any selections
        mLV.clearChoices();/*from  ww  w  .  j  a  va2  s . co  m*/

        // update container
        mContainerCallback.onNoteDeleted();

        // show a toast to confirm delete
        Toast.makeText(getActivity(), String.format(getString(R.string.num_deleted), 1, ""), Toast.LENGTH_SHORT)
                .show();

        showMultiPanel();
        return true;
    }
    return super.onContextItemSelected(item);
}