mirror of
https://github.com/TeamNewPipe/NewPipe
synced 2025-10-25 04:17:39 +00:00
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.
This commit is contained in:
@@ -366,15 +366,20 @@ public final class Player implements PlaybackListener, Listener {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Resolve enqueue intents
|
// Resolve enqueue intents
|
||||||
if (intent.getBooleanExtra(ENQUEUE, false) && playQueue != null) {
|
if (intent.getBooleanExtra(ENQUEUE, false)) {
|
||||||
|
if (playQueue != null) {
|
||||||
playQueue.append(newQueue.getStreams());
|
playQueue.append(newQueue.getStreams());
|
||||||
|
}
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
// Resolve enqueue next intents
|
// Resolve enqueue next intents
|
||||||
} else if (intent.getBooleanExtra(ENQUEUE_NEXT, false) && playQueue != null) {
|
if (intent.getBooleanExtra(ENQUEUE_NEXT, false)) {
|
||||||
|
if (playQueue != null) {
|
||||||
final int currentIndex = playQueue.getIndex();
|
final int currentIndex = playQueue.getIndex();
|
||||||
playQueue.append(newQueue.getStreams());
|
playQueue.append(newQueue.getStreams());
|
||||||
playQueue.move(playQueue.size() - 1, currentIndex + 1);
|
playQueue.move(playQueue.size() - 1, currentIndex + 1);
|
||||||
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user