Fix a potential exception in shuffle()

If getCurrentPlayingIndex() returns -1,
then remove() fails
This commit is contained in:
tzugen 2021-06-14 21:17:29 +02:00
parent 8c2896ea16
commit 16c6b6b03e
No known key found for this signature in database
GPG Key ID: 61E9C34BC10EC930
1 changed files with 2 additions and 3 deletions

View File

@ -1,7 +1,5 @@
package org.moire.ultrasonic.service;
import timber.log.Timber;
import org.moire.ultrasonic.domain.MusicDirectory;
import org.moire.ultrasonic.util.LRUCache;
import org.moire.ultrasonic.util.ShufflePlayBuffer;
@ -16,6 +14,7 @@ import java.util.concurrent.ScheduledExecutorService;
import java.util.concurrent.TimeUnit;
import kotlin.Lazy;
import timber.log.Timber;
import static org.koin.java.KoinJavaComponent.inject;
import static org.moire.ultrasonic.domain.PlayerState.DOWNLOADING;
@ -342,7 +341,7 @@ public class Downloader
Collections.shuffle(downloadList);
if (localMediaPlayer.currentPlaying != null)
{
downloadList.remove(getCurrentPlayingIndex());
downloadList.remove(localMediaPlayer.currentPlaying);
downloadList.add(0, localMediaPlayer.currentPlaying);
}
revision++;