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.videolan.vlc.gui.video.VideoGridFragment.java

@Override
public boolean onContextItemSelected(MenuItem menu) {
    AdapterContextMenuInfo info = (AdapterContextMenuInfo) menu.getMenuInfo();
    if (info != null && handleContextItemSelected(menu, info.position))
        return true;
    return super.onContextItemSelected(menu);
}

From source file:com.orangelabs.rcs.ri.messaging.chat.single.SingleChatList.java

@Override
public boolean onContextItemSelected(MenuItem item) {
    /* Get selected item */
    AdapterContextMenuInfo info = (AdapterContextMenuInfo) item.getMenuInfo();
    Cursor cursor = (Cursor) (mListView.getAdapter()).getItem(info.position);
    String number = cursor.getString(cursor.getColumnIndexOrThrow(Message.CONTACT));
    ContactId contact = ContactUtil.formatContact(number);
    if (LogUtils.isActive) {
        Log.d(LOGTAG, "onContextItemSelected contact=".concat(contact.toString()));
    }/*  w  w  w. ja va2 s . c o m*/
    switch (item.getItemId()) {
    case CHAT_MENU_ITEM_OPEN:
        if (isServiceConnected(RcsServiceName.CHAT)) {
            /* Open one-to-one chat view */
            startActivity(SingleChatView.forgeIntentToOpenConversation(this, contact));
        } else {
            showMessage(R.string.label_continue_chat_failed);
        }
        return true;

    case CHAT_MENU_ITEM_DELETE:
        if (!isServiceConnected(RcsServiceName.CHAT)) {
            showMessage(R.string.label_delete_chat_failed);
            return true;
        }
        /* Delete messages for contact */
        if (LogUtils.isActive) {
            Log.d(LOGTAG, "Delete messages for contact=".concat(contact.toString()));
        }
        try {
            if (!mOneToOneChatListenerSet) {
                mChatService.addEventListener(mOneChatListener);
                mOneToOneChatListenerSet = true;
            }
            mChatService.deleteOneToOneChat(contact);
        } catch (RcsServiceException e) {
            showExceptionThenExit(e);
        }
        return true;

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

From source file:com.orangelabs.rcs.ri.sharing.image.ImageSharingList.java

@Override
public boolean onContextItemSelected(MenuItem item) {
    /* Get selected item */
    AdapterContextMenuInfo info = (AdapterContextMenuInfo) item.getMenuInfo();
    Cursor cursor = (Cursor) (mListView.getAdapter()).getItem(info.position);
    String sharingId = cursor.getString(cursor.getColumnIndexOrThrow(ImageSharingLog.SHARING_ID));
    if (LogUtils.isActive) {
        Log.d(LOGTAG, "onContextItemSelected sharing ID=".concat(sharingId));
    }//ww  w  .j a  v  a 2 s  . co m
    switch (item.getItemId()) {
    case MENU_ITEM_DELETE:
        if (!isServiceConnected(RcsServiceName.IMAGE_SHARING)) {
            showMessage(R.string.label_service_not_available);
            return true;
        }
        /* Delete messages for contact */
        if (LogUtils.isActive) {
            Log.d(LOGTAG, "Delete image sharing ID=".concat(sharingId));
        }
        try {
            if (!mImageSharingListenerSet) {
                mImageSharingService.addEventListener(mImageSharingListener);
                mImageSharingListenerSet = true;
            }
            mImageSharingService.deleteImageSharing(sharingId);

        } catch (RcsServiceException e) {
            showExceptionThenExit(e);
        }
        return true;

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

From source file:edu.mit.mobile.android.livingpostcards.CardMediaEditFragment.java

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

    final Uri itemUri = ContentUris.withAppendedId(mUri, info.id);

    switch (item.getItemId()) {
    case R.id.delete:
        showDeleteDialog(itemUri);
        return true;
    default:
        return super.onContextItemSelected(item);
    }
}

From source file:com.droidvnteam.hexagonrom.GestureAnywhereBuilderActivity.java

@Override
public boolean onContextItemSelected(MenuItem item) {
    final AdapterView.AdapterContextMenuInfo menuInfo = (AdapterView.AdapterContextMenuInfo) item.getMenuInfo();
    final NamedGesture gesture = (NamedGesture) menuInfo.targetView.getTag();

    switch (item.getItemId()) {
    case MENU_ID_EDIT:
        editGesture(gesture);/*  w w w.  jav a2  s  .  c  om*/
        return true;
    case MENU_ID_REMOVE:
        deleteGesture(gesture);
        return true;
    }

    return super.onContextItemSelected(item);
}

From source file:com.synchophy.ui.CoverFlowActivity.java

@Override
public boolean onContextItemSelected(MenuItem item) {

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

    final CoverFlow coverFlow = (CoverFlow) findViewById(R.id.coverflow);
    ImageAdapter adapter = (ImageAdapter) coverFlow.getAdapter();

    int position = info.position;
    Artist artist = new Artist(adapter.getAlbumArtist(position), 0);
    Album album = new Album(adapter.getAlbumLabel(position), 0, artist);

    switch (item.getItemId()) {
    case R.id.addItem:
        album.addType(this);
        return true;
    case R.id.addItemAndPlay:
        album.addAndPlayType(this);
        return true;
    case R.id.tagItem:
        album.tag(this);
        return true;
    case R.id.tagList:
        album.tagList(this);
        return true;
    case R.id.downloadItem:
        album.download(this);
        return true;
    case R.id.editItem:
        album.edit(this);
        return true;
    default:/*from   w w w. j a  v a2 s. c o  m*/
        return super.onContextItemSelected(item);
    }
}

From source file:org.videolan.vlc.gui.PlaylistActivity.java

@Override
public boolean onContextItemSelected(MenuItem menu) {
    ContextMenuRecyclerView.RecyclerContextMenuInfo info = (ContextMenuRecyclerView.RecyclerContextMenuInfo) menu
            .getMenuInfo();//w  ww. j a va2s .  co  m

    return info != null && handleContextItemSelected(menu, info.position);
}

From source file:com.akhbulatov.wordkeeper.ui.fragment.CategoryListFragment.java

@Override
public boolean onContextItemSelected(MenuItem item) {
    ContextMenuRecyclerView.RecyclerContextMenuInfo info = (ContextMenuRecyclerView.RecyclerContextMenuInfo) item
            .getMenuInfo();//from  ww  w  .  j av  a  2 s  . co m
    switch (item.getItemId()) {
    case R.id.menu_rename_category:
        mSelectedItemId = info.id;
        showCategoryEditorDialog(R.string.title_rename_category, R.string.category_editor_action_rename,
                android.R.string.cancel);
        return true;
    case R.id.menu_delete_category:
        mSelectedItemId = info.id;
        showCategoryDeleteDialog();
        return true;
    default:
        return super.onContextItemSelected(item);
    }
}

From source file:com.dhara.googlecalendartrial.MainActivity.java

@Override
public boolean onContextItemSelected(MenuItem item) {
    switch (item.getItemId()) {
    case 1:/*from www.jav  a2s .  c  o  m*/
        try {
            AdapterContextMenuInfo info = (AdapterContextMenuInfo) item.getMenuInfo();
            Log.d("dhara", "removing item pos=" + info.position);
            Event event = mEventList.get(info.position);
            service.events().delete(mUserAccount, event.getId()).execute();
            mEventList.remove(info.position);
            mEventsAdapter.notifyDataSetChanged();
        } catch (IOException e) {
            e.printStackTrace();
        }
        return true;
    default:
        return super.onContextItemSelected(item);
    }
}

From source file:com.akop.bach.fragment.playstation.GamesFragment.java

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

    if (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_trophies_f, vh.title.getText()));

            startActivity(searchIntent);
            return true;
        }/*from w w  w.ja v a  2  s. c o m*/
    }

    return super.onContextItemSelected(menuItem);
}