Reformat and tweak javadoc

This commit is contained in:
Ian Baker 2024-08-29 10:24:54 +01:00
parent cd47e2a134
commit a4aa975a26
5 changed files with 13 additions and 24 deletions

View File

@ -97,7 +97,8 @@ import java.util.ArrayList;
bundledCustomSpans.add(bundle); bundledCustomSpans.add(bundle);
} }
for (VoiceSpan span : text.getSpans(0, text.length(), VoiceSpan.class)) { for (VoiceSpan span : text.getSpans(0, text.length(), VoiceSpan.class)) {
Bundle bundle = spanToBundle(text, span, /* spanType= */ VOICE, /* params= */ span.toBundle()); Bundle bundle =
spanToBundle(text, span, /* spanType= */ VOICE, /* params= */ span.toBundle());
bundledCustomSpans.add(bundle); bundledCustomSpans.add(bundle);
} }
return bundledCustomSpans; return bundledCustomSpans;

View File

@ -23,10 +23,10 @@ import androidx.media3.common.util.UnstableApi;
import androidx.media3.common.util.Util; import androidx.media3.common.util.Util;
/** /**
* A span representing a speaker. * A span representing the speaker of the spanned text.
* *
* <p>More information on <a href="https://www.w3.org/TR/webvtt1/#webvtt-cue-voice-span"> * <p>For example a <a href="https://www.w3.org/TR/webvtt1/#webvtt-cue-voice-span">WebVTT voice
* voice spans</a>. * span</a>.
*/ */
@UnstableApi @UnstableApi
public final class VoiceSpan { public final class VoiceSpan {
@ -47,6 +47,6 @@ public final class VoiceSpan {
} }
public static VoiceSpan fromBundle(Bundle bundle) { public static VoiceSpan fromBundle(Bundle bundle) {
return new VoiceSpan(/* name = */ checkNotNull(bundle.getString(FIELD_NAME))); return new VoiceSpan(checkNotNull(bundle.getString(FIELD_NAME)));
} }
} }

View File

@ -247,9 +247,7 @@ public final class WebvttCueParserTest {
Spanned text = parseCueText("<v>Text with a single voice span"); Spanned text = parseCueText("<v>Text with a single voice span");
assertThat(text.toString()).isEqualTo("Text with a single voice span"); assertThat(text.toString()).isEqualTo("Text with a single voice span");
assertThat(text) assertThat(text).hasVoiceSpanBetween(0, "Text with a single voice span".length()).withName("");
.hasVoiceSpanBetween(0, "Text with a single voice span".length())
.withName("");
} }
@Test @Test

View File

@ -53,7 +53,6 @@ import java.util.ArrayList;
import java.util.Arrays; import java.util.Arrays;
import java.util.Collections; import java.util.Collections;
import java.util.List; import java.util.List;
import java.util.Objects;
import org.checkerframework.checker.nullness.qual.RequiresNonNull; import org.checkerframework.checker.nullness.qual.RequiresNonNull;
/** A Truth {@link Subject} for assertions on {@link Spanned} instances containing text styling. */ /** A Truth {@link Subject} for assertions on {@link Spanned} instances containing text styling. */
@ -1380,7 +1379,7 @@ public final class SpannedSubject extends Subject {
@Override @Override
public int hashCode() { public int hashCode() {
return Objects.hash(name); return name.hashCode();
} }
@Override @Override

View File

@ -906,9 +906,7 @@ public class SpannedSubjectTest {
@Test @Test
public void voiceSpan_success() { public void voiceSpan_success() {
SpannableString spannable = SpannableString spannable =
createSpannable( createSpannable(new VoiceSpan("speaker"), Spanned.SPAN_INCLUSIVE_EXCLUSIVE);
new VoiceSpan("speaker"),
Spanned.SPAN_INCLUSIVE_EXCLUSIVE);
assertThat(spannable) assertThat(spannable)
.hasVoiceSpanBetween(SPAN_START, SPAN_END) .hasVoiceSpanBetween(SPAN_START, SPAN_END)
@ -919,8 +917,7 @@ public class SpannedSubjectTest {
@Test @Test
public void voiceSpan_wrongEndIndex() { public void voiceSpan_wrongEndIndex() {
checkHasSpanFailsDueToIndexMismatch( checkHasSpanFailsDueToIndexMismatch(
new VoiceSpan("speaker"), new VoiceSpan("speaker"), SpannedSubject::hasVoiceSpanBetween);
SpannedSubject::hasVoiceSpanBetween);
} }
@Test @Test
@ -944,25 +941,19 @@ public class SpannedSubjectTest {
public void voiceSpan_wrongFlags() { public void voiceSpan_wrongFlags() {
checkHasSpanFailsDueToFlagMismatch( checkHasSpanFailsDueToFlagMismatch(
new VoiceSpan("speaker"), new VoiceSpan("speaker"),
(subject, start, end) -> (subject, start, end) -> subject.hasVoiceSpanBetween(start, end).withName("speaker"));
subject
.hasVoiceSpanBetween(start, end)
.withName("speaker"));
} }
@Test @Test
public void noVoiceSpan_success() { public void noVoiceSpan_success() {
SpannableString spannable = SpannableString spannable = createSpannableWithUnrelatedSpanAnd(new VoiceSpan("speaker"));
createSpannableWithUnrelatedSpanAnd(new VoiceSpan("speaker"));
assertThat(spannable).hasNoVoiceSpanBetween(UNRELATED_SPAN_START, UNRELATED_SPAN_END); assertThat(spannable).hasNoVoiceSpanBetween(UNRELATED_SPAN_START, UNRELATED_SPAN_END);
} }
@Test @Test
public void noVoiceSpan_failure() { public void noVoiceSpan_failure() {
checkHasNoSpanFails( checkHasNoSpanFails(new VoiceSpan("speaker"), SpannedSubject::hasNoVoiceSpanBetween);
new VoiceSpan("speaker"),
SpannedSubject::hasNoVoiceSpanBetween);
} }
private interface HasSpanFunction<T> { private interface HasSpanFunction<T> {