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);
}
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);
}
return bundledCustomSpans;

View File

@ -23,10 +23,10 @@ import androidx.media3.common.util.UnstableApi;
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">
* voice spans</a>.
* <p>For example a <a href="https://www.w3.org/TR/webvtt1/#webvtt-cue-voice-span">WebVTT voice
* span</a>.
*/
@UnstableApi
public final class VoiceSpan {
@ -47,6 +47,6 @@ public final class VoiceSpan {
}
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");
assertThat(text.toString()).isEqualTo("Text with a single voice span");
assertThat(text)
.hasVoiceSpanBetween(0, "Text with a single voice span".length())
.withName("");
assertThat(text).hasVoiceSpanBetween(0, "Text with a single voice span".length()).withName("");
}
@Test

View File

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

View File

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