diff --git a/library/core/src/main/java/com/google/android/exoplayer2/text/webvtt/WebvttCssStyle.java b/library/core/src/main/java/com/google/android/exoplayer2/text/webvtt/WebvttCssStyle.java index 2bd1af01e8..9186455702 100644 --- a/library/core/src/main/java/com/google/android/exoplayer2/text/webvtt/WebvttCssStyle.java +++ b/library/core/src/main/java/com/google/android/exoplayer2/text/webvtt/WebvttCssStyle.java @@ -17,7 +17,9 @@ package com.google.android.exoplayer2.text.webvtt; import android.graphics.Typeface; import android.text.Layout; +import android.text.TextUtils; import androidx.annotation.IntDef; +import androidx.annotation.Nullable; import com.google.android.exoplayer2.util.Util; import java.lang.annotation.Documented; import java.lang.annotation.Retention; @@ -25,6 +27,7 @@ import java.lang.annotation.RetentionPolicy; import java.util.Arrays; import java.util.Collections; import java.util.List; +import org.checkerframework.checker.nullness.qual.EnsuresNonNull; /** * Style object of a Css style block in a Webvtt file. @@ -80,7 +83,7 @@ public final class WebvttCssStyle { private String targetVoice; // Style properties. - private String fontFamily; + @Nullable private String fontFamily; private int fontColor; private boolean hasFontColor; private int backgroundColor; @@ -91,12 +94,16 @@ public final class WebvttCssStyle { @OptionalBoolean private int italic; @FontSizeUnit private int fontSizeUnit; private float fontSize; - private Layout.Alignment textAlign; + @Nullable private Layout.Alignment textAlign; + // Calling reset() is forbidden because `this` isn't initialized. This can be safely suppressed + // because reset() only assigns fields, it doesn't read any. + @SuppressWarnings("nullness:method.invocation.invalid") public WebvttCssStyle() { reset(); } + @EnsuresNonNull({"targetId", "targetTag", "targetClasses", "targetVoice"}) public void reset() { targetId = ""; targetTag = ""; @@ -133,14 +140,13 @@ public final class WebvttCssStyle { * Returns a value in a score system compliant with the CSS Specificity rules. * * @see CSS Cascading - * - * The score works as follows: - *
The score works as follows: + *