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.deliciousdroid.fragment.BrowseBookmarkFeedFragment.java

@Override
public boolean onContextItemSelected(MenuItem aItem) {
    AdapterContextMenuInfo menuInfo = (AdapterContextMenuInfo) aItem.getMenuInfo();
    final Cursor c = (Cursor) lv.getItemAtPosition(menuInfo.position);
    Bookmark b = BookmarkManager.CursorToBookmark(c);

    switch (aItem.getItemId()) {
    case R.id.menu_bookmark_context_open:
        openBookmarkInBrowser(b);// w  w w.ja v  a  2  s.c o m
        return true;
    case R.id.menu_bookmark_context_view:
        viewBookmark(b);
        return true;
    case R.id.menu_bookmark_context_add:
        bookmarkSelectedListener.onBookmarkAdd(b);
        return true;
    case R.id.menu_bookmark_context_read:
        readBookmark(b);
        return true;
    case R.id.menu_bookmark_context_share:
        bookmarkSelectedListener.onBookmarkShare(b);
        return true;
    }
    return false;
}

From source file:org.melato.android.bookmark.BookmarksActivity.java

@Override
public boolean onContextItemSelected(MenuItem item) {
    if (!hasContextMenu)
        return false;
    AdapterContextMenuInfo info = (AdapterContextMenuInfo) item.getMenuInfo();
    Bookmark bookmark = bookmarks.get(info.position);
    int itemId = item.getItemId();
    if (itemId == R.id.open) {
        open(bookmark);//from   w w  w .j av  a2s .c o m
        return true;
    } else if (itemId == R.id.delete) {
        BookmarkDatabase.getInstance(this).deleteBookmark(bookmark);
        bookmarks.remove(info.position);
        adapter.notifyDataSetChanged();
        return true;
    } else if (itemId == R.id.rename) {
        renameBookmark(bookmark, info.position);
        return true;
    } else {
        return false;
    }
}

From source file:biz.incomsystems.fwknop2.ConfigListFragment.java

@Override
public boolean onContextItemSelected(MenuItem item) {
    customAdapter = (ArrayAdapter) getListAdapter();
    info = (AdapterView.AdapterContextMenuInfo) item.getMenuInfo();
    switch (item.getItemId()) {
    case R.id.delete: // Deleting the selected option
        AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());
        builder.setMessage("Are you sure?").setPositiveButton("Yes", dialogClickListener)
                .setNegativeButton("No", dialogClickListener).show();

        return true;

    case R.id.knock:
        String nick = ((TextView) info.targetView).getText().toString();
        OurSender.send(nick, getActivity());

    default:/*from ww w  .  j  a  v  a2  s. c  om*/
        return super.onContextItemSelected(item);
    }
}

From source file:com.example.Bama.chat.chatuidemo.activity.ChatHistoryFragment.java

@Override
public boolean onContextItemSelected(MenuItem item) {
    if (item.getItemId() == R.id.delete_message) {
        EMContact tobeDeleteUser = adapter.getItem(((AdapterContextMenuInfo) item.getMenuInfo()).position);
        boolean isGroup = false;
        if (tobeDeleteUser instanceof EMGroup)
            isGroup = true;//  w  w  w.j  ava 2 s. c  o  m
        // ?
        EMChatManager.getInstance().deleteConversation(tobeDeleteUser.getUsername(), isGroup);
        InviteMessgeDao inviteMessgeDao = new InviteMessgeDao(getActivity());
        inviteMessgeDao.deleteMessage(tobeDeleteUser.getUsername());
        adapter.remove(tobeDeleteUser);
        adapter.notifyDataSetChanged();

        // ?,
        //         if(((ActivityMain) getActivity()).myChatFragment != null){
        //            ((ActivityMain) getActivity()).myChatFragment.updateUnreadLabel();
        //         }

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

From source file:org.peterbaldwin.vlcremote.fragment.PlaylistFragment.java

@Override
public boolean onContextItemSelected(MenuItem menuItem) {
    ContextMenuInfo menuInfo = menuItem.getMenuInfo();
    if (menuInfo instanceof AdapterContextMenuInfo) {
        AdapterContextMenuInfo info = (AdapterContextMenuInfo) menuInfo;
        if (info.position < mAdapter.getCount()) {
            PlaylistItem item = mAdapter.getItem(info.position);
            switch (menuItem.getItemId()) {
            case R.id.playlist_context_play:
                selectItem(item);//w  w  w.j  a va2  s .  c  o  m
                return true;
            case R.id.playlist_context_dequeue:
                removeItem(item, info.position);
                return true;
            case R.id.playlist_context_search:
                searchForItem(item);
                return true;
            }
        }
    }
    return super.onContextItemSelected(menuItem);
}

From source file:net.illusor.swipeplayer.fragments.FolderBrowserFragment.java

@Override
public boolean onContextItemSelected(MenuItem item) {
    if (!this.getUserVisibleHint())
        return false;

    AdapterView.AdapterContextMenuInfo info = (AdapterView.AdapterContextMenuInfo) item.getMenuInfo();
    AudioFile audioFile = (AudioFile) this.listAudioFiles.getItemAtPosition(info.position);
    this.getSwipeActivity().playMediaDirectory(audioFile);
    return true;//from  w ww  .jav a2 s  . c o  m
}

From source file:org.videolan.vlc2.gui.DirectoryViewFragment.java

@Override
public boolean onContextItemSelected(MenuItem item) {
    if (!getUserVisibleHint())
        return super.onContextItemSelected(item);

    AdapterContextMenuInfo info = (AdapterContextMenuInfo) item.getMenuInfo();
    if (info == null) // info can be null
        return super.onContextItemSelected(item);

    int id = item.getItemId();
    String mediaLocation = mDirectoryAdapter.getMediaLocation(info.position);
    if (mediaLocation == null)
        return super.onContextItemSelected(item);

    if (id == R.id.directory_view_play) {
        openMediaFile(info.position);/*from   w w w  .  j ava  2 s. c  om*/
        return true;
    } else if (id == R.id.directory_view_append) {
        AudioServiceController.getInstance().append(mediaLocation);
        return true;
    } else if (id == R.id.directory_view_delete) {
        AlertDialog alertDialog = CommonDialogs.deleteMedia(getActivity(), mediaLocation, new VLCRunnable() {
            @Override
            public void run(Object o) {
                refresh();
            }
        });
        alertDialog.show();
        return true;
    } else if (id == R.id.directory_view_play_audio) {
        AudioServiceController.getInstance().load(mediaLocation, true);
        return true;
    } else if (id == R.id.directory_view_play_video) {
        VideoPlayerActivity.start(getActivity(), mediaLocation);
        return true;
    }
    return super.onContextItemSelected(item);
}

From source file:br.com.bioscada.apps.biotracks.MarkerListActivity.java

@Override
public boolean onContextItemSelected(MenuItem item) {
    AdapterContextMenuInfo info = (AdapterContextMenuInfo) item.getMenuInfo();
    if (handleContextItem(item.getItemId(), new long[] { info.id })) {
        return true;
    }//from w  ww  .j  a v  a2  s  . c  o m
    return super.onContextItemSelected(item);
}

From source file:com.andrew.apollo.ui.fragments.ThemeFragment.java

/**
 * {@inheritDoc}/*from w ww.ja  v  a2s  .c  o  m*/
 */
@Override
public boolean onContextItemSelected(final android.view.MenuItem item) {
    final AdapterContextMenuInfo info = (AdapterContextMenuInfo) item.getMenuInfo();
    switch (item.getItemId()) {
    case OPEN_IN_PLAY_STORE:
        ThemeUtils.openAppPage(getSherlockActivity(), mValues[info.position]);
        return true;
    default:
        break;
    }
    return super.onContextItemSelected(item);
}

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

@Override
public boolean onContextItemSelected(MenuItem item) {
    AdapterView.AdapterContextMenuInfo info;
    try {//from   w ww  . j  av  a2 s .c  om
        info = (AdapterView.AdapterContextMenuInfo) item.getMenuInfo();
    } catch (final ClassCastException e) {
        Log.e(TAG, "bad menuInfo", e);
        return false;
    }
    final Uri card = ContentUris.withAppendedId(mCards, info.id);

    switch (item.getItemId()) {
    case R.id.share:
        send(mAdapter.getCursor());
        return true;

    case R.id.edit:
        startActivity(new Intent(Intent.ACTION_EDIT, card));
        return true;

    case R.id.delete:
        startActivity(new Intent(Intent.ACTION_DELETE, card));
        return true;
    default:
        return super.onContextItemSelected(item);
    }

}