From af936bc64602126f1ed06e477bc748ef617f6370 Mon Sep 17 00:00:00 2001 From: litetex <40789489+litetex@users.noreply.github.com> Date: Sat, 23 Oct 2021 17:35:42 +0200 Subject: [PATCH] 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)! --- .../org/schabi/newpipe/player/playqueue/PlayQueue.java | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/app/src/main/java/org/schabi/newpipe/player/playqueue/PlayQueue.java b/app/src/main/java/org/schabi/newpipe/player/playqueue/PlayQueue.java index 014c13339..76fed8e9e 100644 --- a/app/src/main/java/org/schabi/newpipe/player/playqueue/PlayQueue.java +++ b/app/src/main/java/org/schabi/newpipe/player/playqueue/PlayQueue.java @@ -436,14 +436,16 @@ public abstract class PlayQueue implements Serializable { * top, so shuffling a size-2 list does nothing) */ 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 if (size() <= 2) { return; } - // Create a backup if it doesn't already exist - if (backup == null) { - backup = new ArrayList<>(streams); - } final int originalIndex = getIndex(); final PlayQueueItem currentItem = getItem();