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.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.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   ww w.  j av  a  2  s  .  com
            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:com.guayaba.tapir.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.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   ww  w. j av a2  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:
            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:com.guayaba.tapir.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.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  va2  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:
            DeleteDialog.newInstance(mSong.mSongName, new long[] { mSelectedId }, null)
                    .show(getFragmentManager(), "DeleteDialog");
            refresh();
            return true;
        default:
            break;
        }
    }
    return super.onContextItemSelected(item);
}

From source file:com.boko.vimusic.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 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.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 . jav a  2 s .  c  o  m*/
            return true;
        default:
            break;
        }
    }
    return super.onContextItemSelected(item);
}

From source file:com.boko.vimusic.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 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");
            SystemClock.sleep(10);/*from   w  ww .ja v  a  2 s  .  c  om*/
            mAdapter.notifyDataSetChanged();
            getLoaderManager().restartLoader(LOADER, null, this);
            return true;
        default:
            break;
        }
    }
    return super.onContextItemSelected(item);
}

From source file:com.phonemetra.deskclock.DeskClock.java

private boolean processMenuClick(MenuItem item) {
    switch (item.getItemId()) {
    case R.id.menu_item_settings:
        startActivity(new Intent(DeskClock.this, SettingsActivity.class));
        return true;
    case R.id.menu_item_widget_settings:
        Intent wsi = new Intent();
        wsi.setComponent(sWidgetSettingComponentName);
        try {//w  ww  .j  a  v a  2 s .  com
            startActivity(wsi);
        } catch (ActivityNotFoundException e) {
            Toast.makeText(this, getResources().getString(R.string.activity_not_found), Toast.LENGTH_SHORT)
                    .show();
            Log.w(LOG_TAG, "Cannot find the activity!");
        }
        return true;
    case R.id.menu_item_help:
        Intent i = item.getIntent();
        if (i != null) {
            try {
                startActivity(i);
            } catch (ActivityNotFoundException e) {
                // No activity found to match the intent - ignore
            }
        }
        return true;
    case R.id.menu_item_night_mode:
        startActivity(new Intent(DeskClock.this, ScreensaverActivity.class));
    default:
        break;
    }
    return true;
}

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();// www.j  a  v  a 2  s  .  c  o  m
            return true;
        default:
            break;
        }
    }
    return super.onContextItemSelected(item);
}

From source file:de.vanita5.twittnuker.activity.support.MediaViewerActivity.java

public boolean onMenuItemClick(final MenuItem item) {
    switch (item.getItemId()) {
    case MENU_SAVE: {
        if (mImageFile != null) {
            new SaveImageTask(this, mImageFile).execute();
        }/*from w  ww  . j  a v  a 2 s . co  m*/
        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.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);/*  www  . ja v  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:
            mShouldRefresh = true;
            DeleteDialog.newInstance(mSong.mSongName, new long[] { mSelectedId }, null)
                    .show(getFragmentManager(), "DeleteDialog");
            return true;
        default:
            break;
        }
    }
    return super.onContextItemSelected(item);
}

From source file:org.zirco.ui.activities.MainActivity.java

@Override
public boolean onContextItemSelected(MenuItem item) {

    if ((item != null) && (item.getIntent() != null)) {
        Bundle b = item.getIntent().getExtras();

        switch (item.getItemId()) {
        case CONTEXT_MENU_OPEN:
            if (b != null) {
                navigateToUrl(b.getString(Constants.EXTRA_ID_URL));
            }/*from  w  w w . j  a v  a 2  s  .  c o m*/
            return true;

        case CONTEXT_MENU_OPEN_IN_NEW_TAB:
            if (b != null) {
                addTab(false, mCurrentDisplayedViewIndex + 1);
                navigateToUrl(b.getString(Constants.EXTRA_ID_URL));
            }
            return true;

        case CONTEXT_MENU_DOWNLOAD:
            if (b != null) {
                doDownloadStart(b.getString(Constants.EXTRA_ID_URL), null, null, null, 0);
            }
            return true;
        case CONTEXT_MENU_COPY:
            if (b != null) {
                ApplicationUtils.copyTextToClipboard(this, b.getString(Constants.EXTRA_ID_URL),
                        getString(R.string.Commons_UrlCopyToastMessage));
            }
            return true;
        case CONTEXT_MENU_SHARE:
            if (b != null) {
                ApplicationUtils.sharePage(this, "", b.getString(Constants.EXTRA_ID_URL));
            }
            return true;
        default:
            return super.onContextItemSelected(item);
        }
    }

    return super.onContextItemSelected(item);
}