Skip to content

Commit

Permalink
Only show "Enqueue next" when in the middle of the queue
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
Douile committed Aug 25, 2022
1 parent 75917c7 commit a824f11
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -252,10 +252,12 @@ public Builder setAction(@NonNull final StreamDialogDefaultEntry entry,
* @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) {
final int size = holder.getQueueSize();
if (size > 1 && holder.getQueuePosition() < size - 1) {
addEntry(StreamDialogDefaultEntry.ENQUEUE_NEXT);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,13 @@ public int getQueueSize() {
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;

Expand Down

0 comments on commit a824f11

Please sign in to comment.