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.boko.vimusic.ui.fragments.AlbumFragment.java

/**
 * {@inheritDoc}/*  www .  ja va2 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.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:com.andrew.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(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:
            DeleteDialog.newInstance(mSong.mSongName, new long[] { mSelectedId }, null)
                    .show(getFragmentManager(), "DeleteDialog");
            SystemClock.sleep(10);/*from   ww  w . j  av a2  s  .  c om*/
            mAdapter.notifyDataSetChanged();
            getLoaderManager().restartLoader(LOADER, null, this);
            return true;
        default:
            break;
        }
    }
    return super.onContextItemSelected(item);
}

From source file:com.andrew.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(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.USE_AS_RINGTONE:
            MusicUtils.setRingtone(getSherlockActivity(), mSelectedId);
            return true;
        case FragmentMenuItems.DELETE:
            DeleteDialog.newInstance(mSong.mSongName, new long[] { mSelectedId }, null)
                    .show(getFragmentManager(), "DeleteDialog");
            refresh();/*from w  w w .jav  a 2 s. c  o  m*/
            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 w  ww  . jav a  2  s.  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:
            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.andrew.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(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:
            DeleteDialog.newInstance(mSong.mSongName, new long[] { mSelectedId }, null)
                    .show(getFragmentManager(), "DeleteDialog");
            refresh();//from  w w w.  ja  v  a 2s .  c o m
            return true;
        default:
            break;
        }
    }
    return super.onContextItemSelected(item);
}

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

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

From source file:org.mariotaku.twidere.fragment.support.UserListDetailsFragment.java

@Override
public boolean onMenuItemClick(final MenuItem item) {
    switch (item.getItemId()) {
    case MENU_ADD: {
        if (mUserList == null || mUserList.user_id != mUserList.account_id)
            return false;
        final Intent intent = new Intent(INTENT_ACTION_SELECT_USER);
        intent.setClass(getActivity(), UserListSelectorActivity.class);
        intent.putExtra(EXTRA_ACCOUNT_ID, mUserList.account_id);
        startActivityForResult(intent, REQUEST_SELECT_USER);
        break;//from  www .j  av  a 2  s  . c  o m
    }
    case MENU_DELETE: {
        if (mUserList.user_id != mUserList.account_id)
            return false;
        DestroyUserListDialogFragment.show(getFragmentManager(), mUserList);
        break;
    }
    default: {
        if (item.getIntent() != null) {
            try {
                startActivity(item.getIntent());
            } catch (final ActivityNotFoundException e) {
                Log.w(LOGTAG, e);
                return false;
            }
        }
        break;
    }
    }
    return true;
}

From source file:org.mariotaku.twidere.fragment.UserListDetailsFragment.java

@Override
public boolean onMenuItemClick(final MenuItem item) {
    switch (item.getItemId()) {
    case MENU_ADD: {
        final Bundle args = new Bundle();
        args.putLong(INTENT_KEY_ACCOUNT_ID, mAccountId);
        args.putString(INTENT_KEY_TEXT, "");
        args.putInt(INTENT_KEY_LIST_ID, mUserList.getId());
        mAddMemberDialogFragment.setArguments(args);
        mAddMemberDialogFragment.show(getFragmentManager(), "add_member");
        break;// w ww .  j  av  a 2 s. c  o  m
    }
    case MENU_DELETE: {
        if (mUserId != mAccountId)
            return false;
        mTwitterWrapper.destroyUserList(mAccountId, mUserListId);
        break;
    }
    default: {
        if (item.getIntent() != null) {
            try {
                startActivity(item.getIntent());
            } catch (final ActivityNotFoundException e) {
                Log.w(LOGTAG, e);
                return false;
            }
        }
        break;
    }
    }
    return true;
}

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

/**
 * {@inheritDoc}//w  w  w  . j a  v  a 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:
            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);
}