Example usage for android.view MenuItem getIntent

List of usage examples for android.view MenuItem getIntent

Introduction

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

Prototype

public Intent getIntent();

Source Link

Document

Return the Intent associated with this item.

Usage

From source file:ru.mtuci.musicanalyzer.apollo.ui.fragments.profile.AlbumSongFragment.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  w  ww  .  j a va 2 s. 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.USE_AS_RINGTONE:
            MusicUtils.setRingtone(getActivity(), mSelectedId);
            return true;
        case FragmentMenuItems.DELETE:
            DeleteDialog.newInstance(mSong.mSongName, new long[] { mSelectedId }, null)
                    .show(getFragmentManager(), "DeleteDialog");
            refresh();
            return true;
        default:
            break;
        }
    }
    return super.onContextItemSelected(item);
}

From source file:ru.mtuci.musicanalyzer.apollo.ui.fragments.profile.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.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 ww . j  av  a  2s. c o 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:
            DeleteDialog.newInstance(mSong.mSongName, new long[] { mSelectedId }, null)
                    .show(getFragmentManager(), "DeleteDialog");
            SystemClock.sleep(10);
            mAdapter.notifyDataSetChanged();
            getLoaderManager().restartLoader(LOADER, null, this);
            return true;
        default:
            break;
        }
    }
    return super.onContextItemSelected(item);
}

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

/**
 * {@inheritDoc}//w ww  .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.MORE_BY_ARTIST:
            NavUtils.openArtistProfile(getActivity(), mAlbum.mArtistName);
            return true;
        case FragmentMenuItems.PLAYLIST_SELECTED:
            final long id = item.getIntent().getLongExtra("playlist", 0);
            MusicUtils.addToPlaylist(getActivity(), mAlbumList, id);
            return true;
        case FragmentMenuItems.REMOVE_FROM_RECENT:
            mShouldRefresh = true;
            RecentStore.getInstance(getActivity()).removeItem(mAlbum.mAlbumId);
            MusicUtils.refresh();
            return true;
        case FragmentMenuItems.DELETE:
            mShouldRefresh = true;
            final String album = mAlbum.mAlbumName;
            DeleteDialog.newInstance(album, mAlbumList, album + Config.ALBUM_ART_SUFFIX)
                    .show(getFragmentManager(), "DeleteDialog");
            return true;
        default:
            break;
        }
    }
    return super.onContextItemSelected(item);
}

From source file:com.guayaba.tapir.ui.fragments.RecentFragment.java

/**
 * {@inheritDoc}/*from www  . ja va  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.MORE_BY_ARTIST:
            NavUtils.openArtistProfile(getActivity(), mAlbum.mArtistName);
            return true;
        case FragmentMenuItems.PLAYLIST_SELECTED:
            final long id = item.getIntent().getLongExtra("playlist", 0);
            MusicUtils.addToPlaylist(getActivity(), mAlbumList, id);
            return true;
        case FragmentMenuItems.REMOVE_FROM_RECENT:
            mShouldRefresh = true;
            RecentStore.getInstance(getActivity()).removeItem(mAlbum.mAlbumId);
            MusicUtils.refresh();
            return true;
        case FragmentMenuItems.DELETE:
            mShouldRefresh = true;
            final String album = mAlbum.mAlbumName;
            DeleteDialog
                    .newInstance(album, mAlbumList,
                            ImageFetcher.generateAlbumCacheKey(album, mAlbum.mArtistName))
                    .show(getFragmentManager(), "DeleteDialog");
            return true;
        default:
            break;
        }
    }
    return super.onContextItemSelected(item);
}

From source file:com.nachiket.titan.LibraryActivity.java

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

    Intent intent = item.getIntent();

    switch (item.getItemId()) {
    case MENU_EXPAND:
        expand(intent);/* w ww  .  j av  a  2  s  .  c om*/
        if (mDefaultAction == ACTION_LAST_USED && mLastAction != ACTION_EXPAND) {
            mLastAction = ACTION_EXPAND;
            updateHeaders();
        }
        break;
    case MENU_ENQUEUE:
        pickSongs(intent, ACTION_ENQUEUE);
        break;
    case MENU_PLAY:
        pickSongs(intent, ACTION_PLAY);
        break;
    case MENU_PLAY_ALL:
        pickSongs(intent, ACTION_PLAY_ALL);
        break;
    case MENU_ENQUEUE_ALL:
        pickSongs(intent, ACTION_ENQUEUE_ALL);
        break;
    case MENU_NEW_PLAYLIST: {
        NewPlaylistDialog dialog = new NewPlaylistDialog(this, null, R.string.create, intent);
        dialog.setDismissMessage(mHandler.obtainMessage(MSG_NEW_PLAYLIST, dialog));
        dialog.show();
        break;
    }
    case MENU_RENAME_PLAYLIST: {
        NewPlaylistDialog dialog = new NewPlaylistDialog(this, intent.getStringExtra("title"), R.string.rename,
                intent);
        dialog.setDismissMessage(mHandler.obtainMessage(MSG_RENAME_PLAYLIST, dialog));
        dialog.show();
        break;
    }
    case MENU_DELETE:
        mHandler.sendMessage(mHandler.obtainMessage(MSG_DELETE, intent));
        break;
    case MENU_ADD_TO_PLAYLIST: {
        SubMenu playlistMenu = item.getSubMenu();
        playlistMenu.add(0, MENU_NEW_PLAYLIST, 0, R.string.new_playlist).setIntent(intent);
        Cursor cursor = Playlist.queryPlaylists(getContentResolver());
        if (cursor != null) {
            for (int i = 0, count = cursor.getCount(); i != count; ++i) {
                cursor.moveToPosition(i);
                long id = cursor.getLong(0);
                String name = cursor.getString(1);
                Intent copy = new Intent(intent);
                copy.putExtra("playlist", id);
                copy.putExtra("playlistName", name);
                playlistMenu.add(0, MENU_SELECT_PLAYLIST, 0, name).setIntent(copy);
            }
            cursor.close();
        }
        break;
    }
    case MENU_SELECT_PLAYLIST:
        mHandler.sendMessage(mHandler.obtainMessage(MSG_ADD_TO_PLAYLIST, intent));
        break;
    case MENU_MORE_FROM_ARTIST: {
        String selection;
        if (intent.getIntExtra(LibraryAdapter.DATA_TYPE, -1) == MediaUtils.TYPE_ALBUM) {
            selection = "album_id=";
        } else {
            selection = "_id=";
        }
        selection += intent.getLongExtra(LibraryAdapter.DATA_ID, LibraryAdapter.INVALID_ID);
        setLimiter(MediaUtils.TYPE_ARTIST, selection);
        updateLimiterViews();
        break;
    }
    case MENU_MORE_FROM_ALBUM:
        setLimiter(MediaUtils.TYPE_ALBUM,
                "_id=" + intent.getLongExtra(LibraryAdapter.DATA_ID, LibraryAdapter.INVALID_ID));
        updateLimiterViews();
        break;
    }

    return true;
}

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

/**
 * {@inheritDoc}/*from  w  ww  . j  a  v  a2 s.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.MORE_BY_ARTIST:
            NavUtils.openArtistProfile(getActivity(), mAlbum.mArtistName);
            return true;
        case FragmentMenuItems.PLAYLIST_SELECTED:
            final String id = item.getIntent().getStringExtra("playlist");
            MusicUtils.addToPlaylist(getActivity(), mAlbumList, id);
            return true;
        case FragmentMenuItems.REMOVE_FROM_RECENT:
            mShouldRefresh = true;
            RecentStore.getInstance(getActivity()).removeAlbum(mAlbum.getId(), HostType.LOCAL);
            MusicUtils.refresh(getActivity());
            return true;
        case FragmentMenuItems.DELETE:
            mShouldRefresh = true;
            final String album = mAlbum.getName();
            DeleteDialog
                    .newInstance(album, mAlbumList,
                            ImageFetcher.generateAlbumCacheKey(album, mAlbum.mArtistName))
                    .show(getFragmentManager(), "DeleteDialog");
            return true;
        default:
            break;
        }
    }
    return super.onContextItemSelected(item);
}

From source file:ru.mtuci.musicanalyzer.apollo.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 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   w  ww . j av a2s.c o 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:
            DeleteDialog.newInstance(mSong.mSongName, new long[] { mSelectedId }, null)
                    .show(getFragmentManager(), "DeleteDialog");
            refresh();
            return true;
        default:
            break;
        }
    }
    return super.onContextItemSelected(item);
}

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

/**
 * {@inheritDoc}/*from   ww  w. java  2  s.  com*/
 */
@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.MORE_BY_ARTIST:
            NavUtils.openArtistProfile(getSherlockActivity(), mAlbum.mArtistName);
            return true;
        case FragmentMenuItems.PLAYLIST_SELECTED:
            final long id = item.getIntent().getLongExtra("playlist", 0);
            MusicUtils.addToPlaylist(getSherlockActivity(), mAlbumList, id);
            return true;
        case FragmentMenuItems.REMOVE_FROM_RECENT:
            mShouldRefresh = true;
            RecentStore.getInstance(getSherlockActivity()).removeItem(mAlbum.mAlbumId);
            MusicUtils.refresh();
            return true;
        case FragmentMenuItems.DELETE:
            mShouldRefresh = true;
            final String album = mAlbum.mAlbumName;
            DeleteDialog.newInstance(album, mAlbumList, album + Config.ALBUM_ART_SUFFIX)
                    .show(getFragmentManager(), "DeleteDialog");
            return true;
        default:
            break;
        }
    }
    return super.onContextItemSelected(item);
}

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

/**
 * {@inheritDoc}/*from   w  w w .jav  a2  s . co  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.MORE_BY_ARTIST:
            NavUtils.openArtistProfile(getActivity(), mAlbum.mArtistName);
            return true;
        case FragmentMenuItems.PLAYLIST_SELECTED:
            final long id = item.getIntent().getLongExtra("playlist", 0);
            MusicUtils.addToPlaylist(getActivity(), mAlbumList, id);
            return true;
        case FragmentMenuItems.DELETE:
            mShouldRefresh = true;
            final String album = mAlbum.mAlbumName;
            DeleteDialog.newInstance(album, mAlbumList, album + Config.ALBUM_ART_SUFFIX)
                    .show(getFragmentManager(), "DeleteDialog");
            return true;
        default:
            break;
        }
    }
    return super.onContextItemSelected(item);
}

From source file:com.guayaba.tapir.ui.fragments.AlbumFragment.java

/**
 * {@inheritDoc}//from w  w 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.MORE_BY_ARTIST:
            NavUtils.openArtistProfile(getActivity(), mAlbum.mArtistName);
            return true;
        case FragmentMenuItems.PLAYLIST_SELECTED:
            final long id = item.getIntent().getLongExtra("playlist", 0);
            MusicUtils.addToPlaylist(getActivity(), mAlbumList, id);
            return true;
        case FragmentMenuItems.DELETE:
            mShouldRefresh = true;
            final String album = mAlbum.mAlbumName;
            DeleteDialog
                    .newInstance(album, mAlbumList,
                            ImageFetcher.generateAlbumCacheKey(album, mAlbum.mArtistName))
                    .show(getFragmentManager(), "DeleteDialog");
            return true;
        default:
            break;
        }
    }
    return super.onContextItemSelected(item);
}