Example usage for android.view MenuItem getGroupId

List of usage examples for android.view MenuItem getGroupId

Introduction

In this page you can find the example usage for android.view MenuItem getGroupId.

Prototype

public int getGroupId();

Source Link

Document

Return the group identifier that this menu item is part of.

Usage

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

@Override
public boolean onContextItemSelected(final android.view.MenuItem item) {
    if (item.getGroupId() == GROUP_ID) {
        switch (item.getItemId()) {
        case FragmentMenuItems.PLAY_SELECTION:
            MusicUtils.playAll(getSherlockActivity(), new long[] { mSelectedId }, 0, false);
            return true;
        case FragmentMenuItems.ADD_TO_QUEUE:
            MusicUtils.addToQueue(getSherlockActivity(), new long[] { mSelectedId });
            return true;
        case FragmentMenuItems.ADD_TO_FAVORITES:
            FavoritesStore.getInstance(getSherlockActivity()).addSongId(Long.valueOf(mSelectedId), mSongName,
                    mAlbumName, mArtistName);
            return true;
        case FragmentMenuItems.NEW_PLAYLIST:
            CreateNewPlaylist.getInstance(new long[] { mSelectedId }).show(getFragmentManager(),
                    "CreatePlaylist");
            return true;
        case FragmentMenuItems.PLAYLIST_SELECTED:
            final long mPlaylistId = item.getIntent().getLongExtra("playlist", 0);
            MusicUtils.addToPlaylist(getSherlockActivity(), new long[] { mSelectedId }, mPlaylistId);
            return true;
        case FragmentMenuItems.MORE_BY_ARTIST:
            NavUtils.openArtistProfile(getSherlockActivity(), mArtistName);
            return true;
        case FragmentMenuItems.USE_AS_RINGTONE:
            MusicUtils.setRingtone(getSherlockActivity(), mSelectedId);
            return true;
        case FragmentMenuItems.DELETE:
            mShouldRefresh = true;/*w  w w . j ava  2  s.co m*/
            DeleteDialog.newInstance(mSong.mSongName, new long[] { mSelectedId }, null)
                    .show(getFragmentManager(), "DeleteDialog");
            return true;
        default:
            break;
        }
    }
    return super.onContextItemSelected(item);
}

From source file:org.lyricue.android.PlaylistFragment.java

@Override
public boolean onContextItemSelected(android.view.MenuItem item) {
    if (item.getGroupId() == 1) {
        AdapterView.AdapterContextMenuInfo info = (AdapterView.AdapterContextMenuInfo) item.getMenuInfo();

        long itemid = item.getItemId();

        if (item.getItemId() == 0) {
            Log.i(TAG, "show item:" + itemid);
            activity.ld.runCommand_noreturn("display", String.valueOf(itemid), "");
        } else if (item.getItemId() == 1) {
            Log.i(TAG, "remove item:" + itemid);
            if (activity.hosts != null)
                new RemoveItemTask().execute(itemid);
        }//from  ww w . ja  va  2 s  . c  om
        return true;
    } else {
        return false;
    }

}

From source file:com.cyanogenmod.eleven.utils.PopupMenuHelper.java

@Override
public boolean onMenuItemClick(MenuItem item) {
    if (item.getGroupId() == getGroupId()) {
        switch (item.getItemId()) {
        case FragmentMenuItems.REMOVE_FROM_RECENT:
            RecentStore.getInstance(mActivity).removeItem(getId());
            MusicUtils.refresh();//from www  .  j a v a  2s.c  o  m
            return true;
        case FragmentMenuItems.PLAY_SELECTION:
            MusicUtils.playAll(mActivity, getIdList(), 0, getSourceId(), getSourceType(), false);
            return true;
        case FragmentMenuItems.ADD_TO_QUEUE:
            MusicUtils.addToQueue(mActivity, getIdList(), getSourceId(), getSourceType());
            return true;
        case FragmentMenuItems.ADD_TO_PLAYLIST:
            ContextMenuBuilder builder = new ContextMenuBuilder(mActivity);
            MusicUtils.makePlaylistMenu(mActivity, getGroupId(), builder);
            builder.setHeaderTitle(R.string.add_to_playlist);
            builder.setCallback(new MenuBuilder.Callback() {
                @Override
                public boolean onMenuItemSelected(MenuBuilder menu, MenuItem item) {
                    return onMenuItemClick(item);
                }

                @Override
                public void onMenuModeChange(MenuBuilder menu) {
                    // do nothing
                }
            });
            builder.show(null, null);
            return true;
        case FragmentMenuItems.NEW_PLAYLIST:
            CreateNewPlaylist.getInstance(getIdList()).show(mFragmentManager, "CreatePlaylist");
            return true;
        case FragmentMenuItems.RENAME_PLAYLIST:
            RenamePlaylist.getInstance(getId()).show(mFragmentManager, "RenameDialog");
            return true;
        case FragmentMenuItems.PLAYLIST_SELECTED:
            final long mPlaylistId = item.getIntent().getLongExtra("playlist", 0);
            MusicUtils.addToPlaylist(mActivity, getIdList(), mPlaylistId);
            return true;
        case FragmentMenuItems.MORE_BY_ARTIST:
            NavUtils.openArtistProfile(mActivity, getArtistName());
            return true;
        case FragmentMenuItems.DELETE:
            onDeleteClicked();
            return true;
        case FragmentMenuItems.USE_AS_RINGTONE:
            MusicUtils.setRingtone(mActivity, getId());
            return true;
        case FragmentMenuItems.REMOVE_FROM_PLAYLIST:
            removeFromPlaylist();
            return true;
        case FragmentMenuItems.REMOVE_FROM_QUEUE:
            removeFromQueue();
            return true;
        case FragmentMenuItems.PLAY_NEXT:
            playNext();
            return true;
        case FragmentMenuItems.PLAY_ALBUM:
            playAlbum();
            return true;
        default:
            break;
        }
    }

    return false;
}

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

@Override
public boolean onContextItemSelected(final android.view.MenuItem item) {
    if (item.getGroupId() == GROUP_ID) {
        switch (item.getItemId()) {
        case FragmentMenuItems.PLAY_SELECTION:
            MusicUtils.playAll(getActivity(), new long[] { mSelectedId }, 0, false);
            return true;
        case FragmentMenuItems.PLAY_NEXT:
            MusicUtils.playNext(new long[] { mSelectedId });
            return true;
        case FragmentMenuItems.ADD_TO_QUEUE:
            MusicUtils.addToQueue(getActivity(), new long[] { mSelectedId });
            return true;
        case FragmentMenuItems.ADD_TO_FAVORITES:
            FavoritesStore.getInstance(getActivity()).addSongId(mSelectedId, mSongName, mAlbumName,
                    mArtistName);//from w  w  w . ja v a  2s . c  om
            return true;
        case FragmentMenuItems.NEW_PLAYLIST:
            CreateNewPlaylist.getInstance(new long[] { mSelectedId }).show(getFragmentManager(),
                    "CreatePlaylist");
            return true;
        case FragmentMenuItems.PLAYLIST_SELECTED:
            final long mPlaylistId = item.getIntent().getLongExtra("playlist", 0);
            MusicUtils.addToPlaylist(getActivity(), new long[] { mSelectedId }, mPlaylistId);
            return true;
        case FragmentMenuItems.MORE_BY_ARTIST:
            NavUtils.openArtistProfile(getActivity(), mArtistName);
            return true;
        case FragmentMenuItems.USE_AS_RINGTONE:
            MusicUtils.setRingtone(getActivity(), mSelectedId);
            return true;
        case FragmentMenuItems.DELETE:
            mShouldRefresh = true;
            DeleteDialog.newInstance(mSong.mSongName, new long[] { mSelectedId }, null)
                    .show(getFragmentManager(), "DeleteDialog");
            return true;
        default:
            break;
        }
    }
    return super.onContextItemSelected(item);
}

From source file:com.boko.vimusic.ui.fragments.SongFragment.java

@Override
public boolean onContextItemSelected(final android.view.MenuItem item) {
    if (item.getGroupId() == GROUP_ID) {
        switch (item.getItemId()) {
        case FragmentMenuItems.PLAY_SELECTION:
            MusicUtils.playAll(getActivity(), new Song[] { mSelectedId }, 0, false);
            return true;
        case FragmentMenuItems.PLAY_NEXT:
            MusicUtils.playNext(new Song[] { mSelectedId });
            return true;
        case FragmentMenuItems.ADD_TO_QUEUE:
            MusicUtils.addToQueue(getActivity(), new Song[] { mSelectedId });
            return true;
        case FragmentMenuItems.ADD_TO_FAVORITES:
            FavoritesStore.getInstance(getActivity()).addSong(mSelectedId.getId(), mSelectedId.getHost(),
                    mSongName, mAlbumName, mArtistName);
            return true;
        case FragmentMenuItems.NEW_PLAYLIST:
            CreateNewPlaylist.getInstance(new Song[] { mSelectedId }).show(getFragmentManager(),
                    "CreatePlaylist");
            return true;
        case FragmentMenuItems.PLAYLIST_SELECTED:
            final String mPlaylistId = item.getIntent().getStringExtra("playlist");
            MusicUtils.addToPlaylist(getActivity(), new Song[] { mSelectedId }, mPlaylistId);
            return true;
        case FragmentMenuItems.MORE_BY_ARTIST:
            NavUtils.openArtistProfile(getActivity(), mArtistName);
            return true;
        case FragmentMenuItems.USE_AS_RINGTONE:
            MusicUtils.setRingtone(getActivity(), mSelectedId.getId());
            return true;
        case FragmentMenuItems.DELETE:
            mShouldRefresh = true;/* ww w.  ja  v  a2 s.  c  o  m*/
            DeleteDialog.newInstance(mSong.getName(), new Song[] { mSelectedId }, null)
                    .show(getFragmentManager(), "DeleteDialog");
            return true;
        default:
            break;
        }
    }
    return super.onContextItemSelected(item);
}

From source file:org.yammp.fragment.AlbumFragment.java

@Override
public boolean onContextItemSelected(MenuItem item) {

    if (item.getGroupId() == hashCode()) {
        if (mCursor == null)
            return true;
        switch (item.getItemId()) {
        case PLAY_SELECTION:
            int position = mSelectedPosition;
            long[] list = mUtils.getSongListForAlbum(mSelectedId);
            mUtils.playAll(list, position);
            return true;
        case DELETE_ITEMS:
            DeleteDialogFragment.getInstance(false, mSelectedId, DeleteDialogFragment.ALBUM)
                    .show(getFragmentManager(), "dialog");
            return true;
        case DELETE_LYRICS:
            DeleteDialogFragment.getInstance(false, mSelectedId, DeleteDialogFragment.ALBUM)
                    .show(getFragmentManager(), "dialog");
            return true;
        case SEARCH:
            doSearch();//  www .j  a  v  a 2 s  .  co m
            return true;
        }
    }
    return super.onContextItemSelected(item);
}

From source file:com.guayaba.tapir.ui.fragments.profile.PlaylistSongFragment.java

@Override
public boolean onContextItemSelected(final android.view.MenuItem item) {
    if (item.getGroupId() == GROUP_ID) {
        switch (item.getItemId()) {
        case FragmentMenuItems.PLAY_SELECTION:
            MusicUtils.playAll(getActivity(), new long[] { mSelectedId }, 0, false);
            return true;
        case FragmentMenuItems.PLAY_NEXT:
            MusicUtils.playNext(new long[] { mSelectedId });
            return true;
        case FragmentMenuItems.ADD_TO_QUEUE:
            MusicUtils.addToQueue(getActivity(), new long[] { mSelectedId });
            return true;
        case FragmentMenuItems.ADD_TO_FAVORITES:
            FavoritesStore.getInstance(getActivity()).addSongId(mSelectedId, mSongName, mAlbumName,
                    mArtistName);//  w w w . ja  v  a 2s. com
            return true;
        case FragmentMenuItems.NEW_PLAYLIST:
            CreateNewPlaylist.getInstance(new long[] { mSelectedId }).show(getFragmentManager(),
                    "CreatePlaylist");
            return true;
        case FragmentMenuItems.PLAYLIST_SELECTED:
            final long playlistId = item.getIntent().getLongExtra("playlist", 0);
            MusicUtils.addToPlaylist(getActivity(), new long[] { mSelectedId }, playlistId);
            return true;
        case FragmentMenuItems.MORE_BY_ARTIST:
            NavUtils.openArtistProfile(getActivity(), mArtistName);
            return true;
        case FragmentMenuItems.USE_AS_RINGTONE:
            MusicUtils.setRingtone(getActivity(), mSelectedId);
            return true;
        case FragmentMenuItems.DELETE:
            DeleteDialog.newInstance(mSong.mSongName, new long[] { mSelectedId }, null)
                    .show(getFragmentManager(), "DeleteDialog");
            SystemClock.sleep(10);
            mAdapter.notifyDataSetChanged();
            getLoaderManager().restartLoader(LOADER, null, this);
            return true;
        case FragmentMenuItems.REMOVE_FROM_PLAYLIST:
            mAdapter.remove(mSong);
            mAdapter.notifyDataSetChanged();
            MusicUtils.removeFromPlaylist(getActivity(), mSong.mSongId, mPlaylistId);
            getLoaderManager().restartLoader(LOADER, null, this);
            return true;
        default:
            break;
        }
    }
    return super.onContextItemSelected(item);
}

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

/**
 * {@inheritDoc}/*w w w  .  j  a va  2  s  . c o  m*/
 */
@Override
public boolean onContextItemSelected(final android.view.MenuItem item) {
    if (item.getGroupId() == GROUP_ID) {
        switch (item.getItemId()) {
        case FragmentMenuItems.PLAY_NEXT:
            NowPlayingCursor queue = (NowPlayingCursor) QueueLoader.makeQueueCursor(getSherlockActivity());
            queue.removeItem(mSelectedPosition);
            queue.close();
            queue = null;
            MusicUtils.playNext(new long[] { mSelectedId });
            getLoaderManager().restartLoader(LOADER, null, this);
            return true;
        case FragmentMenuItems.ADD_TO_QUEUE:
            MusicUtils.addToQueue(getSherlockActivity(), new long[] { mSelectedId });
            return true;
        case FragmentMenuItems.ADD_TO_FAVORITES:
            FavoritesStore.getInstance(getSherlockActivity()).addSongId(Long.valueOf(mSelectedId), mSongName,
                    mAlbumName, mArtistName);
            return true;
        case FragmentMenuItems.NEW_PLAYLIST:
            CreateNewPlaylist.getInstance(new long[] { mSelectedId }).show(getFragmentManager(),
                    "CreatePlaylist");
            return true;
        case FragmentMenuItems.PLAYLIST_SELECTED:
            final long mPlaylistId = item.getIntent().getLongExtra("playlist", 0);
            MusicUtils.addToPlaylist(getSherlockActivity(), new long[] { mSelectedId }, mPlaylistId);
            return true;
        case FragmentMenuItems.MORE_BY_ARTIST:
            NavUtils.openArtistProfile(getSherlockActivity(), mArtistName);
            return true;
        case FragmentMenuItems.USE_AS_RINGTONE:
            MusicUtils.setRingtone(getSherlockActivity(), mSelectedId);
            return true;
        // case FragmentMenuItems.DELETE:
        // return true;
        default:
            break;
        }
    }
    return super.onContextItemSelected(item);
}

From source file:ru.mtuci.musicanalyzer.apollo.ui.fragments.QueueFragment.java

/**
 * {@inheritDoc}/*from  w  w w.  ja va 2 s. c  o  m*/
 */
@Override
public boolean onContextItemSelected(final android.view.MenuItem item) {
    if (item.getGroupId() == GROUP_ID) {
        switch (item.getItemId()) {
        case FragmentMenuItems.PLAY_NEXT:
            NowPlayingCursor queue = (NowPlayingCursor) QueueLoader.makeQueueCursor(getActivity());
            queue.removeItem(mSelectedPosition);
            queue.close();
            queue = null;
            MusicUtils.playNext(new long[] { mSelectedId });
            getLoaderManager().restartLoader(LOADER, null, this);
            return true;
        case FragmentMenuItems.ADD_TO_QUEUE:
            MusicUtils.addToQueue(getActivity(), new long[] { mSelectedId });
            return true;
        case FragmentMenuItems.ADD_TO_FAVORITES:
            FavoritesStore.getInstance(getActivity()).addSongId(mSelectedId, mSongName, mAlbumName,
                    mArtistName);
            return true;
        case FragmentMenuItems.NEW_PLAYLIST:
            CreateNewPlaylist.getInstance(new long[] { mSelectedId }).show(getFragmentManager(),
                    "CreatePlaylist");
            return true;
        case FragmentMenuItems.PLAYLIST_SELECTED:
            final long mPlaylistId = item.getIntent().getLongExtra("playlist", 0);
            MusicUtils.addToPlaylist(getActivity(), new long[] { mSelectedId }, mPlaylistId);
            return true;
        case FragmentMenuItems.MORE_BY_ARTIST:
            NavUtils.openArtistProfile(getActivity(), mArtistName);
            return true;
        case FragmentMenuItems.USE_AS_RINGTONE:
            MusicUtils.setRingtone(getActivity(), mSelectedId);
            return true;
        // case FragmentMenuItems.DELETE:
        // return true;
        default:
            break;
        }
    }
    return super.onContextItemSelected(item);
}

From source file:com.boko.vimusic.ui.fragments.profile.PlaylistSongFragment.java

@Override
public boolean onContextItemSelected(final android.view.MenuItem item) {
    if (item.getGroupId() == GROUP_ID) {
        switch (item.getItemId()) {
        case FragmentMenuItems.PLAY_SELECTION:
            MusicUtils.playAll(getActivity(), new Song[] { mSelectedId }, 0, false);
            return true;
        case FragmentMenuItems.PLAY_NEXT:
            MusicUtils.playNext(new Song[] { mSelectedId });
            return true;
        case FragmentMenuItems.ADD_TO_QUEUE:
            MusicUtils.addToQueue(getActivity(), new Song[] { mSelectedId });
            return true;
        case FragmentMenuItems.ADD_TO_FAVORITES:
            FavoritesStore.getInstance(getActivity()).addSong(mSelectedId.getId(), mSelectedId.getHost(),
                    mSongName, mAlbumName, mArtistName);
            return true;
        case FragmentMenuItems.NEW_PLAYLIST:
            CreateNewPlaylist.getInstance(new Song[] { mSelectedId }).show(getFragmentManager(),
                    "CreatePlaylist");
            return true;
        case FragmentMenuItems.PLAYLIST_SELECTED:
            final String playlistId = item.getIntent().getStringExtra("playlist");
            MusicUtils.addToPlaylist(getActivity(), new Song[] { mSelectedId }, playlistId);
            return true;
        case FragmentMenuItems.MORE_BY_ARTIST:
            NavUtils.openArtistProfile(getActivity(), mArtistName);
            return true;
        case FragmentMenuItems.USE_AS_RINGTONE:
            MusicUtils.setRingtone(getActivity(), mSelectedId.getId());
            return true;
        case FragmentMenuItems.DELETE:
            DeleteDialog.newInstance(mSong.getName(), new Song[] { mSelectedId }, null)
                    .show(getFragmentManager(), "DeleteDialog");
            SystemClock.sleep(10);/*  www.  j a  v a  2 s.com*/
            mAdapter.notifyDataSetChanged();
            getLoaderManager().restartLoader(LOADER, null, this);
            return true;
        case FragmentMenuItems.REMOVE_FROM_PLAYLIST:
            mAdapter.remove(mSong);
            mAdapter.notifyDataSetChanged();
            MusicUtils.removeFromPlaylist(getActivity(), mSong.getId(), mPlaylistId);
            getLoaderManager().restartLoader(LOADER, null, this);
            return true;
        default:
            break;
        }
    }
    return super.onContextItemSelected(item);
}