mirror of
https://github.com/TeamNewPipe/NewPipe
synced 2025-01-25 16:36:57 +00: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
|
// Playback
|
||||||
//////////////////////////////////////////////////////////////////////////*/
|
//////////////////////////////////////////////////////////////////////////*/
|
||||||
|
|
||||||
private PlayQueue playQueue;
|
// play queue might be null e.g. while player is starting
|
||||||
|
@Nullable private PlayQueue playQueue;
|
||||||
private PlayQueueAdapter playQueueAdapter;
|
private PlayQueueAdapter playQueueAdapter;
|
||||||
private StreamSegmentAdapter segmentAdapter;
|
private StreamSegmentAdapter segmentAdapter;
|
||||||
|
|
||||||
@ -4202,6 +4203,7 @@ public final class Player implements
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@Nullable
|
||||||
public PlayQueue getPlayQueue() {
|
public PlayQueue getPlayQueue() {
|
||||||
return playQueue;
|
return playQueue;
|
||||||
}
|
}
|
||||||
|
@ -38,12 +38,12 @@ public final class PlayerHolder {
|
|||||||
private static final boolean DEBUG = MainActivity.DEBUG;
|
private static final boolean DEBUG = MainActivity.DEBUG;
|
||||||
private static final String TAG = PlayerHolder.class.getSimpleName();
|
private static final String TAG = PlayerHolder.class.getSimpleName();
|
||||||
|
|
||||||
private PlayerServiceExtendedEventListener listener;
|
@Nullable private PlayerServiceExtendedEventListener listener;
|
||||||
|
|
||||||
private final PlayerServiceConnection serviceConnection = new PlayerServiceConnection();
|
private final PlayerServiceConnection serviceConnection = new PlayerServiceConnection();
|
||||||
private boolean bound;
|
private boolean bound;
|
||||||
private MainPlayer playerService;
|
@Nullable private MainPlayer playerService;
|
||||||
private Player player;
|
@Nullable private Player player;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the current {@link MainPlayer.PlayerType} of the {@link MainPlayer} service,
|
* Returns the current {@link MainPlayer.PlayerType} of the {@link MainPlayer} service,
|
||||||
@ -75,7 +75,11 @@ public final class PlayerHolder {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public int getQueueSize() {
|
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) {
|
public void setListener(@Nullable final PlayerServiceExtendedEventListener newListener) {
|
||||||
|
Loading…
Reference in New Issue
Block a user