Commit 5407c317 by ibaker Committed by Oliver Woodman

Remove WebvttSubtitle from null-checking blacklist

PiperOrigin-RevId: 277916113
parent 5b80b4b5
...@@ -23,7 +23,6 @@ import com.google.android.exoplayer2.util.Assertions; ...@@ -23,7 +23,6 @@ import com.google.android.exoplayer2.util.Assertions;
import com.google.android.exoplayer2.util.Util; import com.google.android.exoplayer2.util.Util;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Arrays; import java.util.Arrays;
import java.util.Collections;
import java.util.List; import java.util.List;
/** /**
...@@ -73,15 +72,12 @@ import java.util.List; ...@@ -73,15 +72,12 @@ import java.util.List;
@Override @Override
public List<Cue> getCues(long timeUs) { public List<Cue> getCues(long timeUs) {
ArrayList<Cue> list = null; List<Cue> list = new ArrayList<>();
WebvttCue firstNormalCue = null; WebvttCue firstNormalCue = null;
SpannableStringBuilder normalCueTextBuilder = null; SpannableStringBuilder normalCueTextBuilder = null;
for (int i = 0; i < numCues; i++) { for (int i = 0; i < numCues; i++) {
if ((cueTimesUs[i * 2] <= timeUs) && (timeUs < cueTimesUs[i * 2 + 1])) { if ((cueTimesUs[i * 2] <= timeUs) && (timeUs < cueTimesUs[i * 2 + 1])) {
if (list == null) {
list = new ArrayList<>();
}
WebvttCue cue = cues.get(i); WebvttCue cue = cues.get(i);
// TODO(ibaker): Replace this with a closer implementation of the WebVTT spec (keeping // TODO(ibaker): Replace this with a closer implementation of the WebVTT spec (keeping
// individual cues, but tweaking their `line` value): // individual cues, but tweaking their `line` value):
...@@ -94,9 +90,12 @@ import java.util.List; ...@@ -94,9 +90,12 @@ import java.util.List;
firstNormalCue = cue; firstNormalCue = cue;
} else if (normalCueTextBuilder == null) { } else if (normalCueTextBuilder == null) {
normalCueTextBuilder = new SpannableStringBuilder(); normalCueTextBuilder = new SpannableStringBuilder();
normalCueTextBuilder.append(firstNormalCue.text).append("\n").append(cue.text); normalCueTextBuilder
.append(Assertions.checkNotNull(firstNormalCue.text))
.append("\n")
.append(Assertions.checkNotNull(cue.text));
} else { } else {
normalCueTextBuilder.append("\n").append(cue.text); normalCueTextBuilder.append("\n").append(Assertions.checkNotNull(cue.text));
} }
} else { } else {
list.add(cue); list.add(cue);
...@@ -110,12 +109,7 @@ import java.util.List; ...@@ -110,12 +109,7 @@ import java.util.List;
// there was only a single normal cue, so just add it to the list // there was only a single normal cue, so just add it to the list
list.add(firstNormalCue); list.add(firstNormalCue);
} }
if (list != null) {
return list; return list;
} else {
return Collections.emptyList();
}
} }
} }
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