fix possible endless loop
We were hanging there if a user selected the previous album if: * He already was at the first album * And FINISH_RANDOM was enabled The new code is somewhat simpler to read and handles the case where we hit song 0 in random mode.
This commit is contained in:
parent
2df538ccc5
commit
b90cc98377
@ -691,14 +691,22 @@ public final class SongTimeline {
|
|||||||
else if (delta == SHIFT_PREVIOUS_SONG || delta == SHIFT_NEXT_SONG) {
|
else if (delta == SHIFT_PREVIOUS_SONG || delta == SHIFT_NEXT_SONG) {
|
||||||
shiftCurrentSongInternal(delta);
|
shiftCurrentSongInternal(delta);
|
||||||
} else {
|
} else {
|
||||||
Song song = getSong(0);
|
Song currentSong = getSong(0);
|
||||||
long currentAlbum = song.albumId;
|
Song song = currentSong;
|
||||||
long currentSong = song.id;
|
|
||||||
delta = delta > 0 ? 1 : -1;
|
delta = delta > 0 ? 1 : -1;
|
||||||
do {
|
for (;;) {
|
||||||
shiftCurrentSongInternal(delta);
|
shiftCurrentSongInternal(delta);
|
||||||
song = getSong(0);
|
song = getSong(0);
|
||||||
} while (currentAlbum == song.albumId && currentSong != song.id);
|
|
||||||
|
if (currentSong == null || song == null)
|
||||||
|
break;
|
||||||
|
if (currentSong.albumId != song.albumId) // found a new album
|
||||||
|
break;
|
||||||
|
if (currentSong.id == song.id) // probably looping? (= only one album in queue)
|
||||||
|
break;
|
||||||
|
if (getPosition() == 0 && getFinishAction() == FINISH_RANDOM) // dead end: FINISH_RANDOM won't wrap around.
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user