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: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  .j  a va  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 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.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;/*from   w  w w  .  j  a  v a2  s.co  m*/
            DeleteDialog.newInstance(mSong.getName(), new Song[] { mSelectedId }, null)
                    .show(getFragmentManager(), "DeleteDialog");
            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);//from   w w w  .ja v a2s.  co  m
            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);
}

From source file:com.android.music.AlbumBrowserFragment.java

@Override
public boolean onContextItemSelected(MenuItem item) {
    switch (item.getItemId()) {
    case PLAY_SELECTION: {
        // play the selected album
        long[] list = MusicUtils.getSongListForAlbum(getActivity(), Long.parseLong(mCurrentAlbumId));
        MusicUtils.playAll(getActivity(), list, 0);
        return true;
    }/* www  .  j a v a  2s .c  om*/

    case QUEUE: {
        long[] list = MusicUtils.getSongListForAlbum(getActivity(), Long.parseLong(mCurrentAlbumId));
        MusicUtils.addToCurrentPlaylist(getActivity(), list);
        return true;
    }

    case NEW_PLAYLIST: {
        Intent intent = new Intent();
        intent.setClass(getActivity(), CreatePlaylist.class);
        startActivityForResult(intent, NEW_PLAYLIST);
        return true;
    }

    case PLAYLIST_SELECTED: {
        long[] list = MusicUtils.getSongListForAlbum(getActivity(), Long.parseLong(mCurrentAlbumId));
        long playlist = item.getIntent().getLongExtra("playlist", 0);
        MusicUtils.addToPlaylist(getActivity(), list, playlist);
        return true;
    }
    case DELETE_ITEM: {
        long[] list = MusicUtils.getSongListForAlbum(getActivity(), Long.parseLong(mCurrentAlbumId));
        String f;
        if (android.os.Environment.isExternalStorageRemovable()) {
            f = getString(R.string.delete_album_desc);
        } else {
            f = getString(R.string.delete_album_desc_nosdcard);
        }
        String desc = String.format(f, mCurrentAlbumName);
        Bundle b = new Bundle();
        b.putString("description", desc);
        b.putLongArray("items", list);
        Intent intent = new Intent();
        intent.setClass(getActivity(), DeleteItems.class);
        intent.putExtras(b);
        startActivityForResult(intent, -1);
        return true;
    }
    case SEARCH:
        doSearch();
        return true;

    }
    return super.onContextItemSelected(item);
}

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

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

From source file:com.android.music.AlbumBrowserActivity.java

@Override
public boolean onContextItemSelected(MenuItem item) {

    badSymptoms.saveMenu("popup", item.toString());

    switch (item.getItemId()) {
    case PLAY_SELECTION: {
        // play the selected album
        long[] list = MusicUtils.getSongListForAlbum(this, Long.parseLong(mCurrentAlbumId));
        MusicUtils.playAll(this, list, 0);
        return true;
    }/*from   w ww . j  a v  a2 s  . co  m*/

    case QUEUE: {
        long[] list = MusicUtils.getSongListForAlbum(this, Long.parseLong(mCurrentAlbumId));
        MusicUtils.addToCurrentPlaylist(this, list);
        return true;
    }

    case NEW_PLAYLIST: {
        Intent intent = new Intent();
        intent.setClass(this, CreatePlaylist.class);
        startActivityForResult(intent, NEW_PLAYLIST);
        return true;
    }

    case PLAYLIST_SELECTED: {
        long[] list = MusicUtils.getSongListForAlbum(this, Long.parseLong(mCurrentAlbumId));
        long playlist = item.getIntent().getLongExtra("playlist", 0);
        MusicUtils.addToPlaylist(this, list, playlist);
        return true;
    }
    case DELETE_ITEM: {
        long[] list = MusicUtils.getSongListForAlbum(this, Long.parseLong(mCurrentAlbumId));
        String f;
        if (android.os.Environment.isExternalStorageRemovable()) {
            f = getString(R.string.delete_album_desc);
        } else {
            f = getString(R.string.delete_album_desc_nosdcard);
        }
        String desc = String.format(f, mCurrentAlbumName);
        Bundle b = new Bundle();
        b.putString("description", desc);
        b.putLongArray("items", list);
        Intent intent = new Intent();
        intent.setClass(this, DeleteItems.class);
        intent.putExtras(b);
        startActivityForResult(intent, -1);
        return true;
    }
    case SEARCH:
        doSearch();
        return true;

    }
    return super.onContextItemSelected(item);
}

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

/**
 * {@inheritDoc}/*from w ww.j  a  v  a2 s . c om*/
 */
@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.andrew.apollo.ui.fragments.QueueFragment.java

/**
 * {@inheritDoc}/*from ww  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:org.mariotaku.gallery3d.ImageViewerGLActivity.java

@Override
public boolean onMenuItemClick(final MenuItem item) {
    switch (item.getItemId()) {
    case MENU_SAVE: {
        if (mImageFile != null) {
            new SaveImageTask(this, mImageFile).execute();
        }//from  w  ww  . j  av  a  2  s  .c om
        break;
    }
    case MENU_OPEN_IN_BROWSER: {
        final Intent intent = getIntent();
        intent.setExtrasClassLoader(getClassLoader());
        final Uri uri = intent.getData();
        final Uri orig = intent.getParcelableExtra(EXTRA_URI_ORIG);
        final Uri uriPreferred = orig != null ? orig : uri;
        if (uriPreferred == null)
            return false;
        final String scheme = uriPreferred.getScheme();
        if ("http".equals(scheme) || "https".equals(scheme)) {
            final Intent open_intent = new Intent(Intent.ACTION_VIEW, uriPreferred);
            open_intent.addCategory(Intent.CATEGORY_BROWSABLE);
            try {
                startActivity(open_intent);
            } catch (final ActivityNotFoundException e) {
                // Ignore.
            }
        }
        break;
    }
    default: {
        final Intent intent = item.getIntent();
        if (intent != null) {
            try {
                startActivity(intent);
            } catch (final ActivityNotFoundException e) {
                // Ignore.
            }
            return true;
        }
        return false;
    }
    }
    return true;
}

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

@Override
public boolean onContextItemSelected(final android.view.MenuItem item) {
    if (item.getGroupId() == GROUP_ID) {
        final long[] songList = mSongList != null ? mSongList : new long[] { mSelectedId };

        switch (item.getItemId()) {
        case FragmentMenuItems.PLAY_SELECTION:
            MusicUtils.playAll(songList, 0, false);
            return true;
        case FragmentMenuItems.PLAY_NEXT:
            MusicUtils.playNext(songList);
            return true;
        case FragmentMenuItems.ADD_TO_QUEUE:
            MusicUtils.addToQueue(getActivity(), songList);
            return true;
        case FragmentMenuItems.ADD_TO_FAVORITES:
            onAddToFavorites();//www . j av  a  2  s . c  om
            return true;
        case FragmentMenuItems.REMOVE_FROM_FAVORITES:
            onRemoveFromFavorites();
            return true;
        case FragmentMenuItems.NEW_PLAYLIST:
            CreateNewPlaylist.getInstance(songList).show(getFragmentManager(), "CreatePlaylist");
            return true;
        case FragmentMenuItems.PLAYLIST_SELECTED:
            final long playlistId = item.getIntent().getLongExtra("playlist", 0);
            MusicUtils.addToPlaylist(getActivity(), songList, playlistId);
            refresh();
            return true;
        case FragmentMenuItems.USE_AS_RINGTONE:
            MusicUtils.setRingtone(getActivity(), mSelectedId);
            return true;
        case FragmentMenuItems.DELETE:
            return onDelete(songList);
        case FragmentMenuItems.MORE_BY_ARTIST:
            long artistId = MusicUtils.getIdForArtist(getContext(), mArtistName);
            long[] tracks = MusicUtils.getSongListForArtist(getActivity(), artistId);
            NavUtils.openArtistProfile(getActivity(), mArtistName, tracks);
            return true;
        case FragmentMenuItems.REMOVE_FROM_PLAYLIST:
            return onRemoveFromPlaylist();
        case FragmentMenuItems.REMOVE_FROM_RECENT:
            return onRemoveFromRecent();
        default:
            break;
        }
    }
    return super.onContextItemSelected(item);
}