Search in sources :

Example 1 with CurrentPlaylistView

use of org.gateshipone.malp.application.views.CurrentPlaylistView in project malp by gateship-one.

the class MainActivity method onCreateContextMenu.

@Override
public void onCreateContextMenu(ContextMenu menu, View v, ContextMenu.ContextMenuInfo menuInfo) {
    super.onCreateContextMenu(menu, v, menuInfo);
    if (v.getId() == R.id.main_listview && mNowPlayingDragStatus == DRAG_STATUS.DRAGGED_UP) {
        int position = ((AdapterView.AdapterContextMenuInfo) menuInfo).position;
        MenuInflater inflater = getMenuInflater();
        inflater.inflate(R.menu.context_menu_current_playlist_track, menu);
        // Check if the menu is created for the currently playing song. If this is the case, do not show play as next item.
        MPDCurrentStatus status = MPDStateMonitoringHandler.getHandler().getLastStatus();
        if (status != null && position == status.getCurrentSongIndex()) {
            menu.findItem(R.id.action_song_play_next).setVisible(false);
        }
        CurrentPlaylistView currentPlaylistView = findViewById(R.id.now_playing_playlist);
        if (currentPlaylistView.getItemViewType(position) == CurrentPlaylistAdapter.VIEW_TYPES.TYPE_SECTION_TRACK_ITEM) {
            menu.findItem(R.id.action_remove_album).setVisible(true);
        }
    }
}
Also used : MPDCurrentStatus(org.gateshipone.malp.mpdservice.mpdprotocol.mpdobjects.MPDCurrentStatus) MenuInflater(android.view.MenuInflater) CurrentPlaylistView(org.gateshipone.malp.application.views.CurrentPlaylistView)

Example 2 with CurrentPlaylistView

use of org.gateshipone.malp.application.views.CurrentPlaylistView 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;
}
Also used : AddPathToPlaylist(org.gateshipone.malp.application.callbacks.AddPathToPlaylist) MPDTrack(org.gateshipone.malp.mpdservice.mpdprotocol.mpdobjects.MPDTrack) MPDAlbum(org.gateshipone.malp.mpdservice.mpdprotocol.mpdobjects.MPDAlbum) Bundle(android.os.Bundle) ChoosePlaylistDialog(org.gateshipone.malp.application.fragments.serverfragments.ChoosePlaylistDialog) AdapterView(android.widget.AdapterView) MPDArtist(org.gateshipone.malp.mpdservice.mpdprotocol.mpdobjects.MPDArtist) CurrentPlaylistView(org.gateshipone.malp.application.views.CurrentPlaylistView) SongDetailsDialog(org.gateshipone.malp.application.fragments.serverfragments.SongDetailsDialog)

Aggregations

CurrentPlaylistView (org.gateshipone.malp.application.views.CurrentPlaylistView)2 Bundle (android.os.Bundle)1 MenuInflater (android.view.MenuInflater)1 AdapterView (android.widget.AdapterView)1 AddPathToPlaylist (org.gateshipone.malp.application.callbacks.AddPathToPlaylist)1 ChoosePlaylistDialog (org.gateshipone.malp.application.fragments.serverfragments.ChoosePlaylistDialog)1 SongDetailsDialog (org.gateshipone.malp.application.fragments.serverfragments.SongDetailsDialog)1 MPDAlbum (org.gateshipone.malp.mpdservice.mpdprotocol.mpdobjects.MPDAlbum)1 MPDArtist (org.gateshipone.malp.mpdservice.mpdprotocol.mpdobjects.MPDArtist)1 MPDCurrentStatus (org.gateshipone.malp.mpdservice.mpdprotocol.mpdobjects.MPDCurrentStatus)1 MPDTrack (org.gateshipone.malp.mpdservice.mpdprotocol.mpdobjects.MPDTrack)1