mirror of
https://github.com/TeamNewPipe/NewPipe
synced 2025-01-11 01:40:59 +00:00
Always create a backup list when shuffling
The backup-list has to be created at all cost (even when current list size <= 2). Otherwise it's not possible to enter shuffle-mode (as ``isShuffled()`` always returns false)!
This commit is contained in:
parent
d66f933c69
commit
af936bc646
@ -436,14 +436,16 @@ public abstract class PlayQueue implements Serializable {
|
|||||||
* top, so shuffling a size-2 list does nothing)
|
* top, so shuffling a size-2 list does nothing)
|
||||||
*/
|
*/
|
||||||
public synchronized void shuffle() {
|
public synchronized void shuffle() {
|
||||||
|
// Create a backup if it doesn't already exist
|
||||||
|
// Note: The backup-list has to be created at all cost (even when size <= 2).
|
||||||
|
// Otherwise it's not possible to enter shuffle-mode!
|
||||||
|
if (backup == null) {
|
||||||
|
backup = new ArrayList<>(streams);
|
||||||
|
}
|
||||||
// Can't shuffle an list that's empty or only has one element
|
// Can't shuffle an list that's empty or only has one element
|
||||||
if (size() <= 2) {
|
if (size() <= 2) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
// Create a backup if it doesn't already exist
|
|
||||||
if (backup == null) {
|
|
||||||
backup = new ArrayList<>(streams);
|
|
||||||
}
|
|
||||||
|
|
||||||
final int originalIndex = getIndex();
|
final int originalIndex = getIndex();
|
||||||
final PlayQueueItem currentItem = getItem();
|
final PlayQueueItem currentItem = getItem();
|
||||||
|
Loading…
Reference in New Issue
Block a user