Added option to shuffle all songs from an artist or an album
This commit is contained in:
parent
98a38825ab
commit
c4a62847df
36 changed files with 61 additions and 44 deletions
|
|
@ -85,7 +85,7 @@ public class SongAdapter extends AbsMultiSelectAdapter<SongAdapter.ViewHolder, S
|
|||
);
|
||||
holder.view.setActivated(isChecked(song));
|
||||
} else {
|
||||
holder.songTitle.setText(activity.getResources().getString(R.string.shuffle_all).toUpperCase());
|
||||
holder.songTitle.setText(activity.getResources().getString(R.string.action_shuffle_all).toUpperCase());
|
||||
holder.songTitle.setTextColor(ThemeSingleton.get().positiveColor);
|
||||
holder.songTitle.setTypeface(Typeface.create("sans-serif-medium", Typeface.NORMAL));
|
||||
holder.songInfo.setVisibility(View.GONE);
|
||||
|
|
@ -175,7 +175,7 @@ public class SongAdapter extends AbsMultiSelectAdapter<SongAdapter.ViewHolder, S
|
|||
@Override
|
||||
public void onClick(View v) {
|
||||
if (getItemViewType() == SHUFFLE_BUTTON) {
|
||||
MusicPlayerRemote.shuffleAllSongs(activity);
|
||||
MusicPlayerRemote.shuffleAllSongs(activity, true);
|
||||
} else if (isInQuickSelectMode()) {
|
||||
toggleChecked(getAdapterPosition());
|
||||
} else {
|
||||
|
|
|
|||
|
|
@ -176,11 +176,14 @@ public class MusicPlayerRemote {
|
|||
return false;
|
||||
}
|
||||
|
||||
public static boolean shuffleAllSongs(final Context context) {
|
||||
public static boolean shuffleAllSongs(final Context context, boolean startPlaying) {
|
||||
return openAndShuffleQueue(context, SongLoader.getAllSongs(context), startPlaying);
|
||||
}
|
||||
|
||||
public static boolean openAndShuffleQueue(final Context context, final ArrayList<Song> songs, boolean startPlaying) {
|
||||
if (musicService != null) {
|
||||
ArrayList<Song> songs = SongLoader.getAllSongs(context);
|
||||
if (!songs.isEmpty()) {
|
||||
MusicPlayerRemote.openQueue(songs, new Random().nextInt(songs.size()), true);
|
||||
MusicPlayerRemote.openQueue(songs, new Random().nextInt(songs.size()), startPlaying);
|
||||
setShuffleMode(MusicService.SHUFFLE_MODE_SHUFFLE);
|
||||
}
|
||||
return true;
|
||||
|
|
|
|||
|
|
@ -349,8 +349,8 @@ public class AlbumDetailActivity extends AbsFabActivity implements PaletteColorH
|
|||
case R.id.action_equalizer:
|
||||
NavigationUtil.openEqualizer(this);
|
||||
return true;
|
||||
case R.id.action_shuffle_all:
|
||||
MusicPlayerRemote.shuffleAllSongs(this);
|
||||
case R.id.action_shuffle_album:
|
||||
MusicPlayerRemote.openAndShuffleQueue(this, songs, true);
|
||||
return true;
|
||||
case android.R.id.home:
|
||||
super.onBackPressed();
|
||||
|
|
|
|||
|
|
@ -68,7 +68,7 @@ import butterknife.InjectView;
|
|||
|
||||
/**
|
||||
* A lot of hackery is done in this activity. Changing things may will brake the whole activity.
|
||||
* <p/>
|
||||
* <p>
|
||||
* Should be kinda stable ONLY AS IT IS!!!
|
||||
*/
|
||||
public class ArtistDetailActivity extends AbsFabActivity implements PaletteColorHolder, CabHolder {
|
||||
|
|
@ -392,8 +392,8 @@ public class ArtistDetailActivity extends AbsFabActivity implements PaletteColor
|
|||
case R.id.action_equalizer:
|
||||
NavigationUtil.openEqualizer(this);
|
||||
return true;
|
||||
case R.id.action_shuffle_all:
|
||||
MusicPlayerRemote.shuffleAllSongs(this);
|
||||
case R.id.action_shuffle_artist:
|
||||
MusicPlayerRemote.openAndShuffleQueue(this, songs, true);
|
||||
return true;
|
||||
case android.R.id.home:
|
||||
super.onBackPressed();
|
||||
|
|
|
|||
|
|
@ -342,7 +342,7 @@ public class MainActivity extends AbsFabActivity
|
|||
NavigationUtil.openEqualizer(this);
|
||||
return true;
|
||||
case R.id.action_shuffle_all:
|
||||
MusicPlayerRemote.shuffleAllSongs(this);
|
||||
MusicPlayerRemote.shuffleAllSongs(this, true);
|
||||
return true;
|
||||
case R.id.action_new_playlist:
|
||||
CreatePlaylistDialog.create().show(getSupportFragmentManager(), "CREATE_PLAYLIST");
|
||||
|
|
|
|||
|
|
@ -571,7 +571,7 @@ public class MusicControllerActivity extends AbsFabActivity {
|
|||
NavigationUtil.openEqualizer(this);
|
||||
return true;
|
||||
case R.id.action_shuffle_all:
|
||||
MusicPlayerRemote.shuffleAllSongs(this);
|
||||
MusicPlayerRemote.shuffleAllSongs(this, true);
|
||||
return true;
|
||||
case R.id.action_add_to_playlist:
|
||||
AddToPlaylistDialog.create(song).show(getSupportFragmentManager(), "ADD_PLAYLIST");
|
||||
|
|
|
|||
|
|
@ -15,12 +15,14 @@ import com.kabouzeid.gramophone.R;
|
|||
import com.kabouzeid.gramophone.adapter.songadapter.AbsPlaylistSongAdapter;
|
||||
import com.kabouzeid.gramophone.adapter.songadapter.PlaylistSongAdapter;
|
||||
import com.kabouzeid.gramophone.adapter.songadapter.smartplaylist.SmartPlaylistSongAdapter;
|
||||
import com.kabouzeid.gramophone.helper.MusicPlayerRemote;
|
||||
import com.kabouzeid.gramophone.interfaces.CabHolder;
|
||||
import com.kabouzeid.gramophone.loader.PlaylistSongLoader;
|
||||
import com.kabouzeid.gramophone.misc.DragSortRecycler;
|
||||
import com.kabouzeid.gramophone.model.DataBaseChangedEvent;
|
||||
import com.kabouzeid.gramophone.model.Playlist;
|
||||
import com.kabouzeid.gramophone.model.PlaylistSong;
|
||||
import com.kabouzeid.gramophone.model.Song;
|
||||
import com.kabouzeid.gramophone.model.smartplaylist.SmartPlaylist;
|
||||
import com.kabouzeid.gramophone.ui.activities.base.AbsFabActivity;
|
||||
import com.kabouzeid.gramophone.util.NavigationUtil;
|
||||
|
|
@ -133,6 +135,9 @@ public class PlaylistDetailActivity extends AbsFabActivity implements CabHolder
|
|||
public boolean onOptionsItemSelected(MenuItem item) {
|
||||
int id = item.getItemId();
|
||||
switch (id) {
|
||||
case R.id.action_shuffle_playlist:
|
||||
MusicPlayerRemote.openAndShuffleQueue(this, new ArrayList<Song>(songs), true);
|
||||
return true;
|
||||
case R.id.action_equalizer:
|
||||
NavigationUtil.openEqualizer(this);
|
||||
return true;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue