Skip to content

Commit f4b28f2

Browse files
committed
Player/handleIntent: always early return on ENQUEUE an ENQUEUE_NEXT
We can do this, because: 1. if `playQueue` is not null, we return early 2. if `playQueue` is null and we need to enqueue: - the only “proper” case that could be triggered is the `RESUME_PLAYBACK` case, which is never `true` for the queuing intents, see the comment in `NavigationHelper.enqueueOnPlayer` - the generic `else` case is degenerate, because it would crash on `playQueue` being `null`. This makes some sense, because there is no way to trigger the enqueueing logic via the UI currently if there is no video playing yet, in which case `playQueue` is not `null`. So we need to transform this whole if desaster into a big switch.
1 parent c4d19c9 commit f4b28f2

1 file changed

Lines changed: 11 additions & 6 deletions

File tree

app/src/main/java/org/schabi/newpipe/player/Player.java

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -368,15 +368,20 @@ public void handleIntent(@NonNull final Intent intent) {
368368
}
369369

370370
// Resolve enqueue intents
371-
if (intent.getBooleanExtra(ENQUEUE, false) && playQueue != null) {
372-
playQueue.append(newQueue.getStreams());
371+
if (intent.getBooleanExtra(ENQUEUE, false)) {
372+
if (playQueue != null) {
373+
playQueue.append(newQueue.getStreams());
374+
}
373375
return;
376+
}
374377

375378
// Resolve enqueue next intents
376-
} else if (intent.getBooleanExtra(ENQUEUE_NEXT, false) && playQueue != null) {
377-
final int currentIndex = playQueue.getIndex();
378-
playQueue.append(newQueue.getStreams());
379-
playQueue.move(playQueue.size() - 1, currentIndex + 1);
379+
if (intent.getBooleanExtra(ENQUEUE_NEXT, false)) {
380+
if (playQueue != null) {
381+
final int currentIndex = playQueue.getIndex();
382+
playQueue.append(newQueue.getStreams());
383+
playQueue.move(playQueue.size() - 1, currentIndex + 1);
384+
}
380385
return;
381386
}
382387

0 commit comments

Comments
 (0)