mirror of
https://github.com/TeamNewPipe/NewPipe
synced 2024-11-16 13:53:53 +01:00
Fix NPE and add some @Nullable
s
Fix NullPointerException in PlayerHolder.getQueueSize() and add `@Nullable` here and there so that the linter reports risks of NPEs
This commit is contained in:
parent
ac53196dcc
commit
5108d75682
@ -260,7 +260,8 @@ public final class Player implements
|
||||
// Playback
|
||||
//////////////////////////////////////////////////////////////////////////*/
|
||||
|
||||
private PlayQueue playQueue;
|
||||
// play queue might be null e.g. while player is starting
|
||||
@Nullable private PlayQueue playQueue;
|
||||
private PlayQueueAdapter playQueueAdapter;
|
||||
private StreamSegmentAdapter segmentAdapter;
|
||||
|
||||
@ -4202,6 +4203,7 @@ public final class Player implements
|
||||
}
|
||||
|
||||
|
||||
@Nullable
|
||||
public PlayQueue getPlayQueue() {
|
||||
return playQueue;
|
||||
}
|
||||
|
@ -38,12 +38,12 @@ public final class PlayerHolder {
|
||||
private static final boolean DEBUG = MainActivity.DEBUG;
|
||||
private static final String TAG = PlayerHolder.class.getSimpleName();
|
||||
|
||||
private PlayerServiceExtendedEventListener listener;
|
||||
@Nullable private PlayerServiceExtendedEventListener listener;
|
||||
|
||||
private final PlayerServiceConnection serviceConnection = new PlayerServiceConnection();
|
||||
private boolean bound;
|
||||
private MainPlayer playerService;
|
||||
private Player player;
|
||||
@Nullable private MainPlayer playerService;
|
||||
@Nullable private Player player;
|
||||
|
||||
/**
|
||||
* Returns the current {@link MainPlayer.PlayerType} of the {@link MainPlayer} service,
|
||||
@ -75,7 +75,11 @@ public final class PlayerHolder {
|
||||
}
|
||||
|
||||
public int getQueueSize() {
|
||||
return isPlayerOpen() ? player.getPlayQueue().size() : 0;
|
||||
if (player == null || player.getPlayQueue() == null) {
|
||||
// player play queue might be null e.g. while player is starting
|
||||
return 0;
|
||||
}
|
||||
return player.getPlayQueue().size();
|
||||
}
|
||||
|
||||
public void setListener(@Nullable final PlayerServiceExtendedEventListener newListener) {
|
||||
|
Loading…
Reference in New Issue
Block a user