Skip to content

Commit 4b99cdc

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 07edeac commit 4b99cdc

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
@@ -357,15 +357,20 @@ public void handleIntent(@NonNull final Intent intent) {
357357
}
358358

359359
// Resolve enqueue intents
360-
if (intent.getBooleanExtra(ENQUEUE, false) && playQueue != null) {
361-
playQueue.append(newQueue.getStreams());
360+
if (intent.getBooleanExtra(ENQUEUE, false)) {
361+
if (playQueue != null) {
362+
playQueue.append(newQueue.getStreams());
363+
}
362364
return;
365+
}
363366

364367
// Resolve enqueue next intents
365-
} else if (intent.getBooleanExtra(ENQUEUE_NEXT, false) && playQueue != null) {
366-
final int currentIndex = playQueue.getIndex();
367-
playQueue.append(newQueue.getStreams());
368-
playQueue.move(playQueue.size() - 1, currentIndex + 1);
368+
if (intent.getBooleanExtra(ENQUEUE_NEXT, false)) {
369+
if (playQueue != null) {
370+
final int currentIndex = playQueue.getIndex();
371+
playQueue.append(newQueue.getStreams());
372+
playQueue.move(playQueue.size() - 1, currentIndex + 1);
373+
}
369374
return;
370375
}
371376

0 commit comments

Comments
 (0)