From e5f30a07bf5860944a2c5bb52f650903ed857b4a Mon Sep 17 00:00:00 2001 From: Douile <25043847+Douile@users.noreply.github.com> Date: Thu, 25 Aug 2022 21:25:00 +0100 Subject: [PATCH] Only show "Enqueue next" when in the middle of the queue Add a check that the queue position is not the last in the queue before showing "Enqueue next". Previously the "Enqueue next" action would always be shown if the queue length was greater than one, this meant even if you were at the end of the queue (when "Enqueue" would have the same effect as "Enqueue next") the action would still be shown. --- .../schabi/newpipe/info_list/dialog/InfoItemDialog.java | 5 +++-- .../org/schabi/newpipe/player/helper/PlayerHolder.java | 7 +++++++ 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/app/src/main/java/org/schabi/newpipe/info_list/dialog/InfoItemDialog.java b/app/src/main/java/org/schabi/newpipe/info_list/dialog/InfoItemDialog.java index 61a88bb8f..0c69557bf 100644 --- a/app/src/main/java/org/schabi/newpipe/info_list/dialog/InfoItemDialog.java +++ b/app/src/main/java/org/schabi/newpipe/info_list/dialog/InfoItemDialog.java @@ -252,10 +252,11 @@ public final class InfoItemDialog { * @return the current {@link Builder} instance */ public Builder addEnqueueEntriesIfNeeded() { - if (PlayerHolder.getInstance().isPlayQueueReady()) { + final PlayerHolder holder = PlayerHolder.getInstance(); + if (holder.isPlayQueueReady()) { addEntry(StreamDialogDefaultEntry.ENQUEUE); - if (PlayerHolder.getInstance().getQueueSize() > 1) { + if (holder.getQueuePosition() < holder.getQueueSize() - 1) { addEntry(StreamDialogDefaultEntry.ENQUEUE_NEXT); } } diff --git a/app/src/main/java/org/schabi/newpipe/player/helper/PlayerHolder.java b/app/src/main/java/org/schabi/newpipe/player/helper/PlayerHolder.java index 5eaecd48d..b55a6547a 100644 --- a/app/src/main/java/org/schabi/newpipe/player/helper/PlayerHolder.java +++ b/app/src/main/java/org/schabi/newpipe/player/helper/PlayerHolder.java @@ -92,6 +92,13 @@ public final class PlayerHolder { return player.getPlayQueue().size(); } + public int getQueuePosition() { + if (player == null || player.getPlayQueue() == null) { + return 0; + } + return player.getPlayQueue().getIndex(); + } + public void setListener(@Nullable final PlayerServiceExtendedEventListener newListener) { listener = newListener;