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.guayaba.tapir.ui.fragments.PlaylistFragment.java

/**
 * {@inheritDoc}/*from w  w  w  .j av a  2s  .c  o m*/
 */
@Override
public boolean onContextItemSelected(final android.view.MenuItem item) {
    if (item.getGroupId() == GROUP_ID) {
        final AdapterContextMenuInfo info = (AdapterContextMenuInfo) item.getMenuInfo();
        switch (item.getItemId()) {
        case FragmentMenuItems.PLAY_SELECTION:
            if (info.position == 0) {
                MusicUtils.playFavorites(getActivity());
            } else if (info.position == 1) {
                MusicUtils.playLastAdded(getActivity());
            } else {
                MusicUtils.playPlaylist(getActivity(), mPlaylist.mPlaylistId);
            }
            return true;
        case FragmentMenuItems.ADD_TO_QUEUE:
            long[] list = null;
            if (info.position == 0) {
                list = MusicUtils.getSongListForFavorites(getActivity());
            } else if (info.position == 1) {
                list = MusicUtils.getSongListForLastAdded(getActivity());
            } else {
                list = MusicUtils.getSongListForPlaylist(getActivity(), mPlaylist.mPlaylistId);
            }
            MusicUtils.addToQueue(getActivity(), list);
            return true;
        case FragmentMenuItems.RENAME_PLAYLIST:
            RenamePlaylist.getInstance(mPlaylist.mPlaylistId).show(getFragmentManager(), "RenameDialog");
            return true;
        case FragmentMenuItems.DELETE:
            buildDeleteDialog().show();
            return true;
        default:
            break;
        }
    }
    return super.onContextItemSelected(item);
}

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

/**
 * {@inheritDoc}/*  w  ww .  j a v  a 2s. co  m*/
 */
@Override
public boolean onContextItemSelected(final android.view.MenuItem item) {
    if (item.getGroupId() == GROUP_ID) {
        final AdapterContextMenuInfo info = (AdapterContextMenuInfo) item.getMenuInfo();
        switch (item.getItemId()) {
        case FragmentMenuItems.PLAY_SELECTION:
            if (info.position == 0) {
                MusicUtils.playFavorites(getSherlockActivity());
            } else if (info.position == 1) {
                MusicUtils.playLastAdded(getSherlockActivity());
            } else {
                MusicUtils.playPlaylist(getSherlockActivity(), mPlaylist.mPlaylistId);
            }
            return true;
        case FragmentMenuItems.ADD_TO_QUEUE:
            long[] list = null;
            if (info.position == 0) {
                list = MusicUtils.getSongListForFavorites(getSherlockActivity());
            } else if (info.position == 1) {
                list = MusicUtils.getSongListForLastAdded(getSherlockActivity());
            } else {
                list = MusicUtils.getSongListForPlaylist(getSherlockActivity(), mPlaylist.mPlaylistId);
            }
            MusicUtils.addToQueue(getSherlockActivity(), list);
            return true;
        case FragmentMenuItems.RENAME_PLAYLIST:
            RenamePlaylist.getInstance(Long.valueOf(mPlaylist.mPlaylistId)).show(getFragmentManager(),
                    "RenameDialog");
            return true;
        case FragmentMenuItems.DELETE:
            buildDeleteDialog().show();
            return true;
        default:
            break;
        }
    }
    return super.onContextItemSelected(item);
}

From source file:com.boko.vimusic.ui.fragments.profile.GenreSongFragment.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:
            DeleteDialog.newInstance(mSong.getName(), new Song[] { mSelectedId }, null)
                    .show(getFragmentManager(), "DeleteDialog");
            refresh();//from   w ww. j a v a 2  s .co m
            return true;
        default:
            break;
        }
    }
    return super.onContextItemSelected(item);
}

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

/**
 * {@inheritDoc}/*from   w  w w .  jav a2  s  . c  om*/
 */
@Override
public boolean onContextItemSelected(final android.view.MenuItem item) {
    if (item.getGroupId() == GROUP_ID) {
        final AdapterContextMenuInfo info = (AdapterContextMenuInfo) item.getMenuInfo();
        switch (item.getItemId()) {
        case FragmentMenuItems.PLAY_SELECTION:
            if (info.position == 0) {
                MusicUtils.playFavorites(getActivity());
            } else if (info.position == 1) {
                MusicUtils.playLastAdded(getActivity());
            } else {
                MusicUtils.playPlaylist(getActivity(), mPlaylist.getId());
            }
            return true;
        case FragmentMenuItems.ADD_TO_QUEUE:
            Song[] list = null;
            if (info.position == 0) {
                list = MusicUtils.getSongListForFavorites(getActivity());
            } else if (info.position == 1) {
                list = MusicUtils.getSongListForLastAdded(getActivity());
            } else {
                list = MusicUtils.getSongListForPlaylist(getActivity(), mPlaylist.getId());
            }
            MusicUtils.addToQueue(getActivity(), list);
            return true;
        case FragmentMenuItems.RENAME_PLAYLIST:
            RenamePlaylist.getInstance(mPlaylist.getId()).show(getFragmentManager(), "RenameDialog");
            return true;
        case FragmentMenuItems.DELETE:
            buildDeleteDialog().show();
            return true;
        default:
            break;
        }
    }
    return super.onContextItemSelected(item);
}

From source file:com.github.kanata3249.ffxieq.android.MagicSelectorActivity.java

@Override
public boolean onOptionsItemSelected(MenuItem item) {
    MagicListView flv = (MagicListView) findViewById(R.id.ListView);

    if (item.getGroupId() == R.id.FilterByType) {
        if (item.getItemId() < 0) {
            mFilterByType = "";
        } else {/*from   w w  w . jav a2 s.c om*/
            mFilterByType = (String) item.getTitle();
        }
        flv.setFilterByType(mFilterByType);
        return true;
    }

    switch (item.getItemId()) {
    case R.id.Remove:
        Intent result = new Intent();

        result.putExtra("From", "MagicSelector");
        result.putExtra("Index", mIndex);
        result.putExtra("Id", -1);
        result.putExtra("SubId", mSubId);
        setResult(RESULT_OK, result);
        finish();
        return true;
    case R.id.Filter:
        showDialog(0);
        return true;
    case R.id.ResetFilter:
        if (flv != null) {
            flv.setFilter("");
        }
        mFilterID = -1;
        return true;

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

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

/**
 * {@inheritDoc}/*from ww w. j av  a 2s .c om*/
 */
@Override
public boolean onContextItemSelected(final MenuItem item) {
    // Avoid leaking context menu selections
    if (item.getGroupId() == GROUP_ID) {
        switch (item.getItemId()) {
        case FragmentMenuItems.PLAY_SELECTION:
            MusicUtils.playAll(getActivity(), mAlbumList, 0, false);
            return true;
        case FragmentMenuItems.ADD_TO_QUEUE:
            MusicUtils.addToQueue(getActivity(), mAlbumList);
            return true;
        case FragmentMenuItems.NEW_PLAYLIST:
            CreateNewPlaylist.getInstance(mAlbumList).show(getFragmentManager(), "CreatePlaylist");
            return true;
        case FragmentMenuItems.PLAYLIST_SELECTED:
            final long id = item.getIntent().getLongExtra("playlist", 0);
            MusicUtils.addToPlaylist(getActivity(), mAlbumList, id);
            return true;
        case FragmentMenuItems.DELETE:
            DeleteDialog.newInstance(mAlbum.mAlbumName, mAlbumList, null).show(getFragmentManager(),
                    "DeleteDialog");
            refresh();
            return true;
        default:
            break;
        }
    }
    return super.onContextItemSelected(item);
}

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

/**
 * {@inheritDoc}//from w  w w  .  ja v a 2s. c  o  m
 */
@Override
public boolean onContextItemSelected(final MenuItem item) {
    // Avoid leaking context menu selections
    if (item.getGroupId() == GROUP_ID) {
        switch (item.getItemId()) {
        case FragmentMenuItems.PLAY_SELECTION:
            MusicUtils.playAll(getActivity(), mAlbumList, 0, false);
            return true;
        case FragmentMenuItems.ADD_TO_QUEUE:
            MusicUtils.addToQueue(getActivity(), mAlbumList);
            return true;
        case FragmentMenuItems.NEW_PLAYLIST:
            CreateNewPlaylist.getInstance(mAlbumList).show(getFragmentManager(), "CreatePlaylist");
            return true;
        case FragmentMenuItems.PLAYLIST_SELECTED:
            final String id = item.getIntent().getStringExtra("playlist");
            MusicUtils.addToPlaylist(getActivity(), mAlbumList, id);
            return true;
        case FragmentMenuItems.DELETE:
            DeleteDialog.newInstance(mAlbum.getName(), mAlbumList, null).show(getFragmentManager(),
                    "DeleteDialog");
            refresh();
            return true;
        default:
            break;
        }
    }
    return super.onContextItemSelected(item);
}

From source file:com.andrew.apollo.ui.fragments.profile.ArtistAlbumFragment.java

/**
 * {@inheritDoc}//from  w  ww . j  a  v  a  2s.  c o m
 */
@Override
public boolean onContextItemSelected(final MenuItem item) {
    // Avoid leaking context menu selections
    if (item.getGroupId() == GROUP_ID) {
        switch (item.getItemId()) {
        case FragmentMenuItems.PLAY_SELECTION:
            MusicUtils.playAll(getSherlockActivity(), mAlbumList, 0, false);
            return true;
        case FragmentMenuItems.ADD_TO_QUEUE:
            MusicUtils.addToQueue(getSherlockActivity(), mAlbumList);
            return true;
        case FragmentMenuItems.NEW_PLAYLIST:
            CreateNewPlaylist.getInstance(mAlbumList).show(getFragmentManager(), "CreatePlaylist");
            return true;
        case FragmentMenuItems.PLAYLIST_SELECTED:
            final long id = item.getIntent().getLongExtra("playlist", 0);
            MusicUtils.addToPlaylist(getSherlockActivity(), mAlbumList, id);
            return true;
        case FragmentMenuItems.DELETE:
            DeleteDialog.newInstance(mAlbum.mAlbumName, mAlbumList, null).show(getFragmentManager(),
                    "DeleteDialog");
            refresh();
            return true;
        default:
            break;
        }
    }
    return super.onContextItemSelected(item);
}

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

/**
 * {@inheritDoc}/*from w ww .  j a v a2 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:
            MusicUtils.removeTrack(mSelectedId);
            MusicUtils.playNext(new Song[] { mSelectedId });
            refreshQueue();
            return true;
        case FragmentMenuItems.REMOVE_FROM_QUEUE:
            MusicUtils.removeTrack(mSelectedId);
            refreshQueue();
            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:
            DeleteDialog.newInstance(mSong.getName(), new Song[] { mSelectedId }, null)
                    .show(getFragmentManager(), "DeleteDialog");
            return true;
        default:
            break;
        }
    }
    return super.onContextItemSelected(item);
}

From source file:ru.mtuci.musicanalyzer.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(getActivity(), new long[] { mSelectedId }, 0, false);
            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 ww  w  . jav a2s  . co m
            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);
}