1
0
mirror of https://github.com/TeamNewPipe/NewPipe.git synced 2024-11-22 11:02:35 +01:00

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.
This commit is contained in:
Douile 2022-08-25 21:25:00 +01:00 committed by Stypox
parent 1d53389ca9
commit e5f30a07bf
No known key found for this signature in database
GPG Key ID: 4BDF1B40A49FDD23
2 changed files with 10 additions and 2 deletions

View File

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

View File

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