From 2e161a1f45d8da2bedd2b924da1c90cc68678714 Mon Sep 17 00:00:00 2001 From: Zhiheng Xu Date: Sat, 22 May 2021 13:56:02 -0400 Subject: [PATCH] Change shuffle() guard to check for size <= 2 After testing the app, I realized that shuffling a queue with size 2 does nothing --- .../java/org/schabi/newpipe/player/playqueue/PlayQueue.java | 5 +++-- 1 file changed, 3 insertions(+), 2 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 45f5efa03..014c13339 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 @@ -432,11 +432,12 @@ public abstract class PlayQueue implements Serializable { * Will emit a {@link ReorderEvent} if shuffled. *

* - * @implNote Does nothing if the queue is empty or has a size of 1 + * @implNote Does nothing if the queue has a size <= 2 (the currently playing video must stay on + * top, so shuffling a size-2 list does nothing) */ public synchronized void shuffle() { // Can't shuffle an list that's empty or only has one element - if (size() <= 1) { + if (size() <= 2) { return; } // Create a backup if it doesn't already exist