use of org.gateshipone.malp.application.callbacks.AddPathToPlaylist in project malp by gateship-one.
the class SearchFragment method onContextItemSelected.
/**
* Hook called when an menu item in the context menu is selected.
*
* @param item The menu item that was selected.
* @return True if the hook was consumed here.
*/
@Override
public boolean onContextItemSelected(MenuItem item) {
AdapterView.AdapterContextMenuInfo info = (AdapterView.AdapterContextMenuInfo) item.getMenuInfo();
int position;
if (info == null) {
if (mContextMenuPosition == -1) {
return super.onContextItemSelected(item);
}
position = mContextMenuPosition;
mContextMenuPosition = -1;
} else {
position = info.position;
}
MPDTrack track = (MPDTrack) mFileAdapter.getItem(position);
mListView.requestFocus();
switch(item.getItemId()) {
case R.id.action_song_play:
MPDQueryHandler.playSong(track.getPath());
return true;
case R.id.action_song_enqueue:
MPDQueryHandler.addPath(track.getPath());
return true;
case R.id.action_song_play_next:
MPDQueryHandler.playSongNext(track.getPath());
return true;
case R.id.action_add_to_saved_playlist:
{
// open dialog in order to save the current playlist as a playlist in the mediastore
ChoosePlaylistDialog choosePlaylistDialog = new ChoosePlaylistDialog();
Bundle args = new Bundle();
args.putBoolean(ChoosePlaylistDialog.EXTRA_SHOW_NEW_ENTRY, true);
choosePlaylistDialog.setCallback(new AddPathToPlaylist((MPDFileEntry) mFileAdapter.getItem(position), getContext()));
choosePlaylistDialog.setArguments(args);
choosePlaylistDialog.show(((AppCompatActivity) getContext()).getSupportFragmentManager(), "ChoosePlaylistDialog");
return true;
}
case R.id.action_show_details:
{
// Open song details dialog
SongDetailsDialog songDetailsDialog = new SongDetailsDialog();
Bundle args = new Bundle();
args.putParcelable(SongDetailsDialog.EXTRA_FILE, (MPDTrack) mFileAdapter.getItem(position));
songDetailsDialog.setArguments(args);
songDetailsDialog.show(((AppCompatActivity) getContext()).getSupportFragmentManager(), "SongDetails");
return true;
}
case R.id.action_add_album:
MPDQueryHandler.addArtistAlbum(track.getTrackAlbum(), "", track.getTrackAlbumMBID());
return true;
case R.id.action_play_album:
MPDQueryHandler.playArtistAlbum(track.getTrackAlbum(), "", track.getTrackAlbumMBID());
return true;
case R.id.action_add_artist:
MPDQueryHandler.addArtist(track.getTrackArtist(), mAlbumSortOrder);
return true;
case R.id.action_play_artist:
MPDQueryHandler.playArtist(track.getTrackArtist(), mAlbumSortOrder);
return true;
case R.id.menu_group_album:
case R.id.menu_group_artist:
// Save position for later use
mContextMenuPosition = info.position;
default:
return super.onContextItemSelected(item);
}
}
use of org.gateshipone.malp.application.callbacks.AddPathToPlaylist in project malp by gateship-one.
the class MainActivity method onContextItemSelected.
@Override
public boolean onContextItemSelected(MenuItem item) {
AdapterView.AdapterContextMenuInfo info = (AdapterView.AdapterContextMenuInfo) item.getMenuInfo();
if (info == null) {
return super.onContextItemSelected(item);
}
CurrentPlaylistView currentPlaylistView = findViewById(R.id.now_playing_playlist);
if (currentPlaylistView != null && mNowPlayingDragStatus == DRAG_STATUS.DRAGGED_UP) {
MPDTrack track = (MPDTrack) currentPlaylistView.getItem(info.position);
switch(item.getItemId()) {
case R.id.action_song_play_next:
MPDQueryHandler.playIndexAsNext(info.position);
return true;
case R.id.action_add_to_saved_playlist:
// open dialog in order to save the current playlist as a playlist in the mediastore
ChoosePlaylistDialog choosePlaylistDialog = new ChoosePlaylistDialog();
Bundle args = new Bundle();
args.putBoolean(ChoosePlaylistDialog.EXTRA_SHOW_NEW_ENTRY, true);
choosePlaylistDialog.setCallback(new AddPathToPlaylist(track, this));
choosePlaylistDialog.setArguments(args);
choosePlaylistDialog.show(getSupportFragmentManager(), "ChoosePlaylistDialog");
return true;
case R.id.action_remove_song:
MPDQueryHandler.removeSongFromCurrentPlaylist(info.position);
return true;
case R.id.action_remove_album:
currentPlaylistView.removeAlbumFrom(info.position);
return true;
case R.id.action_show_artist:
if (mUseArtistSort) {
onArtistSelected(new MPDArtist(track.getTrackArtistSort()), null);
} else {
onArtistSelected(new MPDArtist(track.getTrackArtist()), null);
}
return true;
case R.id.action_show_album:
MPDAlbum tmpAlbum = new MPDAlbum(track.getTrackAlbum());
// Set album artist
if (!track.getTrackAlbumArtist().isEmpty()) {
tmpAlbum.setArtistName(track.getTrackAlbumArtist());
} else {
tmpAlbum.setArtistName(track.getTrackArtist());
}
// Set albumartistsort
if (!track.getTrackAlbumArtistSort().isEmpty()) {
tmpAlbum.setArtistSortName(track.getTrackAlbumArtistSort());
} else {
tmpAlbum.setArtistSortName(track.getTrackArtistSort());
}
tmpAlbum.setMBID(track.getTrackAlbumMBID());
onAlbumSelected(tmpAlbum, null);
return true;
case R.id.action_show_details:
// Open song details dialog
SongDetailsDialog songDetailsDialog = new SongDetailsDialog();
Bundle songArgs = new Bundle();
songArgs.putParcelable(SongDetailsDialog.EXTRA_FILE, track);
songDetailsDialog.setArguments(songArgs);
songDetailsDialog.show(getSupportFragmentManager(), "SongDetails");
return true;
}
}
return false;
}
use of org.gateshipone.malp.application.callbacks.AddPathToPlaylist in project malp by gateship-one.
the class PlaylistTracksFragment method onContextItemSelected.
/**
* Hook called when an menu item in the context menu is selected.
*
* @param item The menu item that was selected.
* @return True if the hook was consumed here.
*/
@Override
public boolean onContextItemSelected(MenuItem item) {
AdapterView.AdapterContextMenuInfo info = (AdapterView.AdapterContextMenuInfo) item.getMenuInfo();
if (info == null) {
return super.onContextItemSelected(item);
}
switch(item.getItemId()) {
case R.id.action_song_enqueue:
enqueueTrack(info.position);
return true;
case R.id.action_song_play:
play(info.position);
return true;
case R.id.action_song_play_next:
playNext(info.position);
return true;
case R.id.action_add_to_saved_playlist:
{
// open dialog in order to save the current playlist as a playlist in the mediastore
ChoosePlaylistDialog choosePlaylistDialog = new ChoosePlaylistDialog();
Bundle args = new Bundle();
args.putBoolean(ChoosePlaylistDialog.EXTRA_SHOW_NEW_ENTRY, true);
choosePlaylistDialog.setCallback(new AddPathToPlaylist((MPDFileEntry) mFileAdapter.getItem(info.position), getActivity()));
choosePlaylistDialog.setArguments(args);
choosePlaylistDialog.show(((AppCompatActivity) getContext()).getSupportFragmentManager(), "ChoosePlaylistDialog");
return true;
}
case R.id.action_remove_from_list:
MPDQueryHandler.removeSongFromSavedPlaylist(mPath, info.position);
refreshContent();
return true;
case R.id.action_show_details:
{
// Open song details dialog
SongDetailsDialog songDetailsDialog = new SongDetailsDialog();
Bundle args = new Bundle();
args.putParcelable(SongDetailsDialog.EXTRA_FILE, (MPDTrack) mFileAdapter.getItem(info.position));
songDetailsDialog.setArguments(args);
songDetailsDialog.show(((AppCompatActivity) getContext()).getSupportFragmentManager(), "SongDetails");
return true;
}
default:
return super.onContextItemSelected(item);
}
}
Aggregations