From 835c5e9d43a73398227f8d77a643367b0072bbab Mon Sep 17 00:00:00 2001 From: Avently <7953703+avently@users.noreply.github.com> Date: Sat, 19 Feb 2022 22:12:31 +0300 Subject: [PATCH 1/2] Better equals check It ensures that queues are not the same. Without this check when you have multiple videos in the backstack and navigating back via Back button you'll get duplicated videos --- .../schabi/newpipe/player/playqueue/PlayQueue.java | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) 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 f2259b120..750564ce2 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 @@ -528,7 +528,16 @@ public abstract class PlayQueue implements Serializable { return false; } final PlayQueue other = (PlayQueue) obj; - return streams.equals(other.streams); + if (size() != other.size()) { + return false; + } + for (int i = 0; i < size(); i++) { + // Check is based on URL + if (!streams.get(i).getUrl().equals(other.streams.get(i).getUrl())) { + return false; + } + } + return true; } @Override From 01e0dd50ad4c5c4f9f8ac7b33e50cf749c93f85a Mon Sep 17 00:00:00 2001 From: Avently <7953703+avently@users.noreply.github.com> Date: Wed, 23 Feb 2022 00:53:39 +0300 Subject: [PATCH 2/2] Added serviceId check while comparing PlayQueues --- .../org/schabi/newpipe/player/playqueue/PlayQueue.java | 7 +++++-- 1 file changed, 5 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 750564ce2..f46c9d72f 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 @@ -532,8 +532,11 @@ public abstract class PlayQueue implements Serializable { return false; } for (int i = 0; i < size(); i++) { - // Check is based on URL - if (!streams.get(i).getUrl().equals(other.streams.get(i).getUrl())) { + final PlayQueueItem stream = streams.get(i); + final PlayQueueItem otherStream = other.streams.get(i); + // Check is based on serviceId and URL + if (stream.getServiceId() != otherStream.getServiceId() + || !stream.getUrl().equals(otherStream.getUrl())) { return false; } }