mirror of
https://github.com/ultrasonic/ultrasonic
synced 2025-02-17 04:00:39 +01:00
Fix a potential exception in shuffle()
If getCurrentPlayingIndex() returns -1, then remove() fails
This commit is contained in:
parent
8c2896ea16
commit
16c6b6b03e
@ -1,7 +1,5 @@
|
|||||||
package org.moire.ultrasonic.service;
|
package org.moire.ultrasonic.service;
|
||||||
|
|
||||||
import timber.log.Timber;
|
|
||||||
|
|
||||||
import org.moire.ultrasonic.domain.MusicDirectory;
|
import org.moire.ultrasonic.domain.MusicDirectory;
|
||||||
import org.moire.ultrasonic.util.LRUCache;
|
import org.moire.ultrasonic.util.LRUCache;
|
||||||
import org.moire.ultrasonic.util.ShufflePlayBuffer;
|
import org.moire.ultrasonic.util.ShufflePlayBuffer;
|
||||||
@ -16,6 +14,7 @@ import java.util.concurrent.ScheduledExecutorService;
|
|||||||
import java.util.concurrent.TimeUnit;
|
import java.util.concurrent.TimeUnit;
|
||||||
|
|
||||||
import kotlin.Lazy;
|
import kotlin.Lazy;
|
||||||
|
import timber.log.Timber;
|
||||||
|
|
||||||
import static org.koin.java.KoinJavaComponent.inject;
|
import static org.koin.java.KoinJavaComponent.inject;
|
||||||
import static org.moire.ultrasonic.domain.PlayerState.DOWNLOADING;
|
import static org.moire.ultrasonic.domain.PlayerState.DOWNLOADING;
|
||||||
@ -342,7 +341,7 @@ public class Downloader
|
|||||||
Collections.shuffle(downloadList);
|
Collections.shuffle(downloadList);
|
||||||
if (localMediaPlayer.currentPlaying != null)
|
if (localMediaPlayer.currentPlaying != null)
|
||||||
{
|
{
|
||||||
downloadList.remove(getCurrentPlayingIndex());
|
downloadList.remove(localMediaPlayer.currentPlaying);
|
||||||
downloadList.add(0, localMediaPlayer.currentPlaying);
|
downloadList.add(0, localMediaPlayer.currentPlaying);
|
||||||
}
|
}
|
||||||
revision++;
|
revision++;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user