mirror of
https://github.com/androidx/media.git
synced 2025-04-30 06:46:50 +08:00
Reformat and tweak javadoc
This commit is contained in:
parent
cd47e2a134
commit
a4aa975a26
@ -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;
|
||||
|
@ -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)));
|
||||
}
|
||||
}
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
@ -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> {
|
||||
|
Loading…
x
Reference in New Issue
Block a user