Commit 6c65c27e by olly Committed by bachinger

Remove nullness blacklist for UI module

PiperOrigin-RevId: 283324784
parent d12c7235
...@@ -97,6 +97,42 @@ public final class Assertions { ...@@ -97,6 +97,42 @@ public final class Assertions {
} }
/** /**
* Throws {@link IllegalStateException} if {@code reference} is null.
*
* @param <T> The type of the reference.
* @param reference The reference.
* @return The non-null reference that was validated.
* @throws IllegalStateException If {@code reference} is null.
*/
@SuppressWarnings({"contracts.postcondition.not.satisfied", "return.type.incompatible"})
@EnsuresNonNull({"#1"})
public static <T> T checkStateNotNull(@Nullable T reference) {
if (ExoPlayerLibraryInfo.ASSERTIONS_ENABLED && reference == null) {
throw new IllegalStateException();
}
return reference;
}
/**
* Throws {@link IllegalStateException} if {@code reference} is null.
*
* @param <T> The type of the reference.
* @param reference The reference.
* @param errorMessage The exception message to use if the check fails. The message is converted
* to a string using {@link String#valueOf(Object)}.
* @return The non-null reference that was validated.
* @throws IllegalStateException If {@code reference} is null.
*/
@SuppressWarnings({"contracts.postcondition.not.satisfied", "return.type.incompatible"})
@EnsuresNonNull({"#1"})
public static <T> T checkStateNotNull(@Nullable T reference, Object errorMessage) {
if (ExoPlayerLibraryInfo.ASSERTIONS_ENABLED && reference == null) {
throw new IllegalStateException(String.valueOf(errorMessage));
}
return reference;
}
/**
* Throws {@link NullPointerException} if {@code reference} is null. * Throws {@link NullPointerException} if {@code reference} is null.
* *
* @param <T> The type of the reference. * @param <T> The type of the reference.
......
...@@ -233,18 +233,18 @@ public class PlayerControlView extends FrameLayout { ...@@ -233,18 +233,18 @@ public class PlayerControlView extends FrameLayout {
private final ComponentListener componentListener; private final ComponentListener componentListener;
private final CopyOnWriteArrayList<VisibilityListener> visibilityListeners; private final CopyOnWriteArrayList<VisibilityListener> visibilityListeners;
private final View previousButton; @Nullable private final View previousButton;
private final View nextButton; @Nullable private final View nextButton;
private final View playButton; @Nullable private final View playButton;
private final View pauseButton; @Nullable private final View pauseButton;
private final View fastForwardButton; @Nullable private final View fastForwardButton;
private final View rewindButton; @Nullable private final View rewindButton;
private final ImageView repeatToggleButton; @Nullable private final ImageView repeatToggleButton;
private final ImageView shuffleButton; @Nullable private final ImageView shuffleButton;
private final View vrButton; @Nullable private final View vrButton;
private final TextView durationView; @Nullable private final TextView durationView;
private final TextView positionView; @Nullable private final TextView positionView;
private final TimeBar timeBar; @Nullable private final TimeBar timeBar;
private final StringBuilder formatBuilder; private final StringBuilder formatBuilder;
private final Formatter formatter; private final Formatter formatter;
private final Timeline.Period period; private final Timeline.Period period;
...@@ -299,6 +299,11 @@ public class PlayerControlView extends FrameLayout { ...@@ -299,6 +299,11 @@ public class PlayerControlView extends FrameLayout {
this(context, attrs, defStyleAttr, attrs); this(context, attrs, defStyleAttr, attrs);
} }
@SuppressWarnings({
"nullness:argument.type.incompatible",
"nullness:method.invocation.invalid",
"nullness:methodref.receiver.bound.invalid"
})
public PlayerControlView( public PlayerControlView(
Context context, Context context,
@Nullable AttributeSet attrs, @Nullable AttributeSet attrs,
...@@ -350,7 +355,7 @@ public class PlayerControlView extends FrameLayout { ...@@ -350,7 +355,7 @@ public class PlayerControlView extends FrameLayout {
updateProgressAction = this::updateProgress; updateProgressAction = this::updateProgress;
hideAction = this::hide; hideAction = this::hide;
LayoutInflater.from(context).inflate(controllerLayoutId, this); LayoutInflater.from(context).inflate(controllerLayoutId, /* root= */ this);
setDescendantFocusability(FOCUS_AFTER_DESCENDANTS); setDescendantFocusability(FOCUS_AFTER_DESCENDANTS);
TimeBar customTimeBar = findViewById(R.id.exo_progress); TimeBar customTimeBar = findViewById(R.id.exo_progress);
...@@ -778,6 +783,8 @@ public class PlayerControlView extends FrameLayout { ...@@ -778,6 +783,8 @@ public class PlayerControlView extends FrameLayout {
if (!isVisible() || !isAttachedToWindow) { if (!isVisible() || !isAttachedToWindow) {
return; return;
} }
@Nullable Player player = this.player;
boolean enableSeeking = false; boolean enableSeeking = false;
boolean enablePrevious = false; boolean enablePrevious = false;
boolean enableRewind = false; boolean enableRewind = false;
...@@ -809,16 +816,20 @@ public class PlayerControlView extends FrameLayout { ...@@ -809,16 +816,20 @@ public class PlayerControlView extends FrameLayout {
if (!isVisible() || !isAttachedToWindow || repeatToggleButton == null) { if (!isVisible() || !isAttachedToWindow || repeatToggleButton == null) {
return; return;
} }
if (repeatToggleModes == RepeatModeUtil.REPEAT_TOGGLE_MODE_NONE) { if (repeatToggleModes == RepeatModeUtil.REPEAT_TOGGLE_MODE_NONE) {
repeatToggleButton.setVisibility(GONE); repeatToggleButton.setVisibility(GONE);
return; return;
} }
@Nullable Player player = this.player;
if (player == null) { if (player == null) {
setButtonEnabled(false, repeatToggleButton); setButtonEnabled(false, repeatToggleButton);
repeatToggleButton.setImageDrawable(repeatOffButtonDrawable); repeatToggleButton.setImageDrawable(repeatOffButtonDrawable);
repeatToggleButton.setContentDescription(repeatOffButtonContentDescription); repeatToggleButton.setContentDescription(repeatOffButtonContentDescription);
return; return;
} }
setButtonEnabled(true, repeatToggleButton); setButtonEnabled(true, repeatToggleButton);
switch (player.getRepeatMode()) { switch (player.getRepeatMode()) {
case Player.REPEAT_MODE_OFF: case Player.REPEAT_MODE_OFF:
...@@ -843,6 +854,8 @@ public class PlayerControlView extends FrameLayout { ...@@ -843,6 +854,8 @@ public class PlayerControlView extends FrameLayout {
if (!isVisible() || !isAttachedToWindow || shuffleButton == null) { if (!isVisible() || !isAttachedToWindow || shuffleButton == null) {
return; return;
} }
@Nullable Player player = this.player;
if (!showShuffleButton) { if (!showShuffleButton) {
shuffleButton.setVisibility(GONE); shuffleButton.setVisibility(GONE);
} else if (player == null) { } else if (player == null) {
...@@ -861,6 +874,7 @@ public class PlayerControlView extends FrameLayout { ...@@ -861,6 +874,7 @@ public class PlayerControlView extends FrameLayout {
} }
private void updateTimeline() { private void updateTimeline() {
@Nullable Player player = this.player;
if (player == null) { if (player == null) {
return; return;
} }
...@@ -935,6 +949,7 @@ public class PlayerControlView extends FrameLayout { ...@@ -935,6 +949,7 @@ public class PlayerControlView extends FrameLayout {
return; return;
} }
@Nullable Player player = this.player;
long position = 0; long position = 0;
long bufferedPosition = 0; long bufferedPosition = 0;
if (player != null) { if (player != null) {
...@@ -985,7 +1000,7 @@ public class PlayerControlView extends FrameLayout { ...@@ -985,7 +1000,7 @@ public class PlayerControlView extends FrameLayout {
} }
} }
private void setButtonEnabled(boolean enabled, View view) { private void setButtonEnabled(boolean enabled, @Nullable View view) {
if (view == null) { if (view == null) {
return; return;
} }
...@@ -1129,6 +1144,7 @@ public class PlayerControlView extends FrameLayout { ...@@ -1129,6 +1144,7 @@ public class PlayerControlView extends FrameLayout {
*/ */
public boolean dispatchMediaKeyEvent(KeyEvent event) { public boolean dispatchMediaKeyEvent(KeyEvent event) {
int keyCode = event.getKeyCode(); int keyCode = event.getKeyCode();
@Nullable Player player = this.player;
if (player == null || !isHandledMediaKey(keyCode)) { if (player == null || !isHandledMediaKey(keyCode)) {
return false; return false;
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment