Skip to content

Commit

Permalink
Fixes issue 111.
Browse files Browse the repository at this point in the history
Instead of calling play() when the playlist is empty, show a toast
  • Loading branch information
Adrian Campos authored and oshmoun committed Apr 23, 2017
1 parent e8d5596 commit dcf988d
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -299,7 +299,7 @@ public int onStartCommand(@Nullable Intent intent, int flags, int startId) {
break;
case ACTION_PLAY:
ArrayList<Song> songs = intent.getParcelableArrayListExtra(INTENT_EXTRA_SONGS);
if (songs != null) {
if (songs != null && !songs.isEmpty()) {
int shuffleMode = intent.getIntExtra(INTENT_EXTRA_SHUFFLE_MODE, getShuffleMode());
if (intent.hasExtra(INTENT_EXTRA_SHUFFLE_MODE) && intent.getIntExtra(INTENT_EXTRA_SHUFFLE_MODE, 0) == SHUFFLE_MODE_SHUFFLE) {
int startPosition = 0;
Expand All @@ -311,8 +311,10 @@ public int onStartCommand(@Nullable Intent intent, int flags, int startId) {
} else {
openQueue(songs, 0, false);
}
play();
} else {
Toast.makeText(getApplicationContext(), R.string.no_songs_in_playlist, Toast.LENGTH_LONG).show();
}
play();
break;
case ACTION_REWIND:
back(true);
Expand Down
2 changes: 2 additions & 0 deletions app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -288,4 +288,6 @@

<string name="app_shortcut_last_added_long">@string/last_added</string>
<string name="app_shortcut_last_added_short">@string/last_added</string>

<string name="no_songs_in_playlist">No songs in playlist</string>
</resources>

0 comments on commit dcf988d

Please sign in to comment.