1
0
mirror of https://github.com/TeamNewPipe/NewPipe synced 2024-12-23 08:30:44 +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:
litetex 2021-10-23 17:35:42 +02:00
parent d66f933c69
commit af936bc646

View File

@ -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();