mirror of
https://github.com/samsonjs/media.git
synced 2026-04-27 15:07:40 +00:00
Modify the SsaColor to be more similar to the Optional class.
This commit is contained in:
parent
2241320535
commit
f8a47bc86d
3 changed files with 19 additions and 7 deletions
|
|
@ -308,8 +308,8 @@ public final class SsaDecoder extends SimpleSubtitleDecoder {
|
||||||
|
|
||||||
// Apply primary color.
|
// Apply primary color.
|
||||||
if (style != null) {
|
if (style != null) {
|
||||||
if (style.primaryColor.isSet) {
|
if (style.primaryColor.isSet()) {
|
||||||
spannableText.setSpan(new ForegroundColorSpan(style.primaryColor.value),
|
spannableText.setSpan(new ForegroundColorSpan(style.primaryColor.getColor()),
|
||||||
0, spannableText.length(), SpannableString.SPAN_EXCLUSIVE_EXCLUSIVE);
|
0, spannableText.length(), SpannableString.SPAN_EXCLUSIVE_EXCLUSIVE);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -31,6 +31,7 @@ import com.google.android.exoplayer2.util.Log;
|
||||||
import com.google.android.exoplayer2.util.Util;
|
import com.google.android.exoplayer2.util.Util;
|
||||||
import java.lang.annotation.Documented;
|
import java.lang.annotation.Documented;
|
||||||
import java.lang.annotation.Retention;
|
import java.lang.annotation.Retention;
|
||||||
|
import java.util.NoSuchElementException;
|
||||||
import java.util.regex.Matcher;
|
import java.util.regex.Matcher;
|
||||||
import java.util.regex.Pattern;
|
import java.util.regex.Pattern;
|
||||||
|
|
||||||
|
|
@ -166,14 +167,25 @@ import java.util.regex.Pattern;
|
||||||
|
|
||||||
public static SsaColor UNSET = new SsaColor(0, false);
|
public static SsaColor UNSET = new SsaColor(0, false);
|
||||||
|
|
||||||
public final @ColorInt int value;
|
private final @ColorInt int color;
|
||||||
public final boolean isSet;
|
private final boolean isSet;
|
||||||
|
|
||||||
private SsaColor(@ColorInt int value, boolean isSet) {
|
private SsaColor(@ColorInt int color, boolean isSet) {
|
||||||
this.value = value;
|
this.color = color;
|
||||||
this.isSet = isSet;
|
this.isSet = isSet;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public @ColorInt int getColor() {
|
||||||
|
if (!isSet) {
|
||||||
|
throw new NoSuchElementException("No color is present");
|
||||||
|
}
|
||||||
|
return color;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isSet() {
|
||||||
|
return isSet;
|
||||||
|
}
|
||||||
|
|
||||||
public static SsaColor from(@ColorInt int value) {
|
public static SsaColor from(@ColorInt int value) {
|
||||||
return new SsaColor(value, true);
|
return new SsaColor(value, true);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -90,7 +90,7 @@ public final class ColorParser {
|
||||||
rgbaStringBuilder.insert(2, "0");
|
rgbaStringBuilder.insert(2, "0");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
abgr = (int) Long.parseLong(colorExpression.substring(2), 16);
|
abgr = (int) Long.parseLong(rgbaStringBuilder.substring(2), 16);
|
||||||
} else {
|
} else {
|
||||||
// Parse color from decimal format (bytes order AABBGGRR).
|
// Parse color from decimal format (bytes order AABBGGRR).
|
||||||
abgr = (int) Long.parseLong(colorExpression);
|
abgr = (int) Long.parseLong(colorExpression);
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue