Skip to content

Commit e5f30a0

Browse files
DouileStypox
authored andcommitted
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.
1 parent 1d53389 commit e5f30a0

2 files changed

Lines changed: 10 additions & 2 deletions

File tree

app/src/main/java/org/schabi/newpipe/info_list/dialog/InfoItemDialog.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -252,10 +252,11 @@ public Builder setAction(@NonNull final StreamDialogDefaultEntry entry,
252252
* @return the current {@link Builder} instance
253253
*/
254254
public Builder addEnqueueEntriesIfNeeded() {
255-
if (PlayerHolder.getInstance().isPlayQueueReady()) {
255+
final PlayerHolder holder = PlayerHolder.getInstance();
256+
if (holder.isPlayQueueReady()) {
256257
addEntry(StreamDialogDefaultEntry.ENQUEUE);
257258

258-
if (PlayerHolder.getInstance().getQueueSize() > 1) {
259+
if (holder.getQueuePosition() < holder.getQueueSize() - 1) {
259260
addEntry(StreamDialogDefaultEntry.ENQUEUE_NEXT);
260261
}
261262
}

app/src/main/java/org/schabi/newpipe/player/helper/PlayerHolder.java

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,13 @@ public int getQueueSize() {
9292
return player.getPlayQueue().size();
9393
}
9494

95+
public int getQueuePosition() {
96+
if (player == null || player.getPlayQueue() == null) {
97+
return 0;
98+
}
99+
return player.getPlayQueue().getIndex();
100+
}
101+
95102
public void setListener(@Nullable final PlayerServiceExtendedEventListener newListener) {
96103
listener = newListener;
97104

0 commit comments

Comments
 (0)