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.audiokernel.euphonyrmt.fragments.BrowseFragment.java

private void addAndReplace(final MenuItem item) {
    final AdapterContextMenuInfo info = (AdapterContextMenuInfo) item.getMenuInfo();

    mApp.oMPDAsyncHelper.execAsync(new Runnable() {
        @Override/*from  w w w  . j av  a2 s  .  c om*/
        public void run() {
            boolean replace = false;
            boolean play = false;
            switch (item.getGroupId()) {
            case ADD_REPLACE_PLAY:
                replace = true;
                play = true;
                break;
            case ADD_REPLACE:
                replace = true;
                break;
            case ADD_PLAY:
                final MPDStatus status = mApp.oMPDAsyncHelper.oMPD.getStatus();

                /**
                 * Let the user know if we're not going to play the added music.
                 */
                if (status.isRandom() && status.isState(MPDStatus.STATE_PLAYING)) {
                    Tools.notifyUser(R.string.notPlayingInRandomMode);
                } else {
                    play = true;
                }
                break;
            default:
                break;
            }
            add(mItems.get((int) info.id), replace, play);
        }
    });
}

From source file:org.onebusaway.android.ui.RouteInfoListFragment.java

@Override
public boolean onContextItemSelected(android.view.MenuItem item) {
    ExpandableListView.ExpandableListContextMenuInfo info = (ExpandableListView.ExpandableListContextMenuInfo) item
            .getMenuInfo();/*from   w ww  .j  a va2 s  .c  o  m*/
    switch (item.getItemId()) {
    case CONTEXT_MENU_DEFAULT:
        showArrivals(info.targetView);
        return true;
    case CONTEXT_MENU_SHOWONMAP:
        showOnMap(info.targetView);
        return true;
    default:
        return super.onContextItemSelected(item);
    }
}

From source file:org.totschnig.myexpenses.fragment.PlanList.java

@Override
public boolean onContextItemSelected(MenuItem item) {
    if (!getUserVisibleHint())
        return false;
    ExpandableListContextMenuInfo info = (ExpandableListContextMenuInfo) item.getMenuInfo();
    if (ExpandableListView
            .getPackedPositionType(info.packedPosition) == ExpandableListView.PACKED_POSITION_TYPE_GROUP)
        return ((ManageTemplates) getActivity()).dispatchCommand(item.getItemId(), info.id);
    int group = ExpandableListView.getPackedPositionGroup(info.packedPosition),
            child = ExpandableListView.getPackedPositionChild(info.packedPosition);
    Cursor c = mAdapter.getChild(group, child);
    long date = c.getLong(c.getColumnIndex(Instances.BEGIN));
    long templateId = mTemplatesCursor.getLong(columnIndexRowId);
    Long transactionId = mInstance2TransactionMap.get(info.id);
    Intent i;//from   w ww . j a v a2  s . com
    switch (item.getItemId()) {
    case R.id.CREATE_INSTANCE_EDIT_COMMAND:
        i = new Intent(getActivity(), ExpenseEdit.class);
        i.putExtra("template_id", templateId);
        i.putExtra("instance_id", info.id);
        i.putExtra("instance_date", date);
        startActivity(i);
        return true;
    case R.id.CREATE_INSTANCE_SAVE_COMMAND:
        getActivity().getSupportFragmentManager().beginTransaction()
                .add(TaskExecutionFragment.newInstance(TaskExecutionFragment.TASK_NEW_FROM_TEMPLATE, templateId,
                        new Long[] { info.id, date }), "ASYNC_TASK")
                .commit();
        return true;
    case R.id.EDIT_COMMAND:
        i = new Intent(getActivity(), ExpenseEdit.class);
        i.putExtra(KEY_ROWID, transactionId);
        startActivity(i);
        return true;
    case R.id.CANCEL_PLAN_INSTANCE_COMMAND:
        getActivity().getSupportFragmentManager().beginTransaction()
                .add(TaskExecutionFragment.newInstance(TaskExecutionFragment.TASK_CANCEL_PLAN_INSTANCE, info.id,
                        new Long[] { templateId, transactionId }), "ASYNC_TASK")
                .commit();
        return true;
    case R.id.RESET_PLAN_INSTANCE_COMMAND:
        getActivity().getSupportFragmentManager().beginTransaction()
                .add(TaskExecutionFragment.newInstance(TaskExecutionFragment.TASK_RESET_PLAN_INSTANCE, info.id,
                        transactionId), "ASYNC_TASK")
                .commit();
        mInstance2TransactionMap.remove(info.id);
        return true;
    }
    return false;
}

From source file:org.tigase.mobile.bookmarks.BookmarksActivity.java

@Override
public boolean onContextItemSelected(MenuItem item) {
    ExpandableListContextMenuInfo info = (ExpandableListContextMenuInfo) item.getMenuInfo();
    if (item.getItemId() == R.id.edit) {
        Bookmark bookmark = adapter.getChildById(info.id);
        editItem(bookmark);//w  w w .ja  v a2s .  co m
        return true;
    } else if (item.getItemId() == R.id.remove) {
        Bookmark bookmark = adapter.getChildById(info.id);
        List<Bookmark> bookmarks = new ArrayList<Bookmark>();
        bookmarks.add(bookmark);
        removeItems(bookmarks);
        return true;
    } else {
        return super.onContextItemSelected(item);
    }
}

From source file:com.synox.android.ui.fragment.OCFileListFragment.java

/**
 * {@inhericDoc}// www.jav  a  2 s. c om
 */
@Override
public boolean onContextItemSelected(MenuItem item) {

    AdapterContextMenuInfo info = (AdapterContextMenuInfo) item.getMenuInfo();
    boolean matched = onFileActionChosen(item.getItemId(),
            ((AdapterContextMenuInfo) item.getMenuInfo()).position);
    if (!matched) {
        return super.onContextItemSelected(item);
    } else {
        return matched;
    }
}

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

@Override
public boolean onContextItemSelected(MenuItem item) {
    AdapterView.AdapterContextMenuInfo info;
    try {//from ww  w .ja  v  a 2  s  .  com
        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:the.joevlc.AudioBrowserFragment.java

@Override
public boolean onContextItemSelected(MenuItem item) {
    ContextMenuInfo menuInfo = item.getMenuInfo();
    if (menuInfo == null)
        return super.onContextItemSelected(item);

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

    boolean useAllItems = (id == R.id.audio_list_browser_play_all || id == R.id.audio_list_browser_append_all);
    boolean append = (id == R.id.audio_list_browser_append || id == R.id.audio_list_browser_append_all);

    if (ExpandableListContextMenuInfo.class.isInstance(menuInfo)) {
        ExpandableListContextMenuInfo info = (ExpandableListContextMenuInfo) menuInfo;
        groupPosition = ExpandableListView.getPackedPositionGroup(info.packedPosition);
        childPosition = ExpandableListView.getPackedPositionChild(info.packedPosition);
        if (childPosition < 0)
            childPosition = 0;/*from   w  ww  .j av  a  2 s. c  o  m*/
    } else {
        AdapterContextMenuInfo info = (AdapterContextMenuInfo) menuInfo;
        groupPosition = info.position;
        childPosition = 0;
    }

    if (id == R.id.audio_list_browser_delete) {
        AlertDialog alertDialog = CommonDialogs.deleteMedia(getActivity(),
                mSongsAdapter.getLocation(groupPosition).get(0),
                new VlcRunnable(mSongsAdapter.getItem(groupPosition)) {
                    @Override
                    public void run(Object o) {
                        Media aMedia = (Media) o;
                        mMediaLibrary.getMediaItems().remove(aMedia);
                        updateLists();
                    }
                });
        alertDialog.show();
        return true;
    }

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

    if (useAllItems) {
        startPosition = groupPosition;
        medias = mSongsAdapter.getLocations();
    } else {
        startPosition = 0;
        switch (mFlingViewGroup.getPosition()) {
        case MODE_SONG:
            medias = mSongsAdapter.getLocation(groupPosition);
            break;
        case MODE_ARTIST:
            medias = mArtistsAdapter.getPlaylist(groupPosition, childPosition);
            break;
        case MODE_ALBUM:
            medias = mAlbumsAdapter.getPlaylist(groupPosition, childPosition);
            break;
        case MODE_GENRE:
            medias = mGenresAdapter.getPlaylist(groupPosition, childPosition);
            break;
        default:
            return true;
        }
    }

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

    AudioPlayerActivity.start(getActivity());
    return super.onContextItemSelected(item);
}

From source file:com.nttec.everychan.ui.NewTabFragment.java

@Override
public boolean onContextItemSelected(MenuItem item) {
    int position = ((AdapterView.AdapterContextMenuInfo) item.getMenuInfo()).position;
    switch (item.getItemId()) {
    case R.id.context_menu_quickaccess_move:
        adapter.setDraggingItem(position);
        return true;
    case R.id.context_menu_quickaccess_remove:
        list.remove(position);/* w w w.  ja v a2  s. com*/
        adapter.notifyDataSetChanged();
        saveQuickAccessToPreferences();
        return true;
    }
    return false;
}

From source file:ru.neverdark.phototools.azimuth.PluginActivity.java

@Override
public boolean onContextItemSelected(MenuItem item) {
    AdapterView.AdapterContextMenuInfo info = (AdapterView.AdapterContextMenuInfo) item.getMenuInfo();
    LocationRecord record = mAdapter.getItem(info.position);
    switch (item.getItemId()) {
    case R.id.remove_location:
        showRemoveLocationDialog(record);
        return true;
    }//  w  w w .  ja v a2  s  .  c o  m

    return super.onContextItemSelected(item);
}

From source file:com.flowzr.activity.AccountListFragment.java

@Override
public boolean onContextItemSelected(MenuItem item) {
    super.onContextItemSelected(item);
    AdapterView.AdapterContextMenuInfo mi = (AdapterView.AdapterContextMenuInfo) item.getMenuInfo();
    switch (item.getItemId()) {
    case R.id.context_account_delete_old: {
        deleteOldTransaction(mi.id);/*  w  ww .  j  a v a2  s .  co m*/
    }
    case R.id.context_account_close: {
        closeAccount(mi.id);
    }
    case R.id.context_account_delete:
        deleteItem(selectedId);
        break;
    case R.id.context_account_info:
        showAccountInfo(selectedId);
        break;
    case R.id.context_account_edit:
        editAccount(selectedId);
        break;
    case R.id.context_account_add_transaction:
        addTransaction(selectedId, TransactionActivity.class);
        break;
    case R.id.context_account_add_transfer:
        addTransaction(selectedId, TransferActivity.class);
        break;
    case R.id.context_account_update_balance:
        updateAccountBalance(selectedId);
        break;
    }
    return false;
}