Merge "media: don't rely on Java 6 parseInt error on leading '+' sign"
This commit is contained in:
@@ -558,7 +558,11 @@ class TextTrackCue extends SubtitleTrack.Cue {
|
||||
}
|
||||
}
|
||||
|
||||
/** @hide */
|
||||
/**
|
||||
* Supporting July 10 2013 draft version
|
||||
*
|
||||
* @hide
|
||||
*/
|
||||
class WebVttParser {
|
||||
private static final String TAG = "WebVttParser";
|
||||
private Phase mPhase;
|
||||
@@ -726,15 +730,15 @@ class WebVttParser {
|
||||
"has invalid value", e.getMessage(), value);
|
||||
}
|
||||
} else if (name.equals("lines")) {
|
||||
try {
|
||||
int lines = Integer.parseInt(value);
|
||||
if (lines >= 0) {
|
||||
region.mLines = lines;
|
||||
} else {
|
||||
log_warning("region setting", name, "is negative", value);
|
||||
if (value.matches(".*[^0-9].*")) {
|
||||
log_warning("lines", name, "contains an invalid character", value);
|
||||
} else {
|
||||
try {
|
||||
region.mLines = Integer.parseInt(value);
|
||||
assert(region.mLines >= 0); // lines contains only digits
|
||||
} catch (NumberFormatException e) {
|
||||
log_warning("region setting", name, "is not numeric", value);
|
||||
}
|
||||
} catch (NumberFormatException e) {
|
||||
log_warning("region setting", name, "is not numeric", value);
|
||||
}
|
||||
} else if (name.equals("regionanchor") ||
|
||||
name.equals("viewportanchor")) {
|
||||
@@ -872,26 +876,23 @@ class WebVttParser {
|
||||
}
|
||||
} else if (name.equals("line")) {
|
||||
try {
|
||||
int linePosition;
|
||||
/* TRICKY: we know that there are no spaces in value */
|
||||
assert(value.indexOf(' ') < 0);
|
||||
if (value.endsWith("%")) {
|
||||
linePosition = Integer.parseInt(
|
||||
value.substring(0, value.length() - 1));
|
||||
if (linePosition < 0 || linePosition > 100) {
|
||||
log_warning("cue setting", name, "is out of range", value);
|
||||
continue;
|
||||
}
|
||||
mCue.mSnapToLines = false;
|
||||
mCue.mLinePosition = linePosition;
|
||||
mCue.mLinePosition = parseIntPercentage(value);
|
||||
} else if (value.matches(".*[^0-9].*")) {
|
||||
log_warning("cue setting", name,
|
||||
"contains an invalid character", value);
|
||||
} else {
|
||||
mCue.mSnapToLines = true;
|
||||
mCue.mLinePosition = Integer.parseInt(value);
|
||||
}
|
||||
} catch (NumberFormatException e) {
|
||||
log_warning("cue setting", name,
|
||||
"is not numeric or percentage", value);
|
||||
"is not numeric or percentage", value);
|
||||
}
|
||||
// TODO: add support for optional alignment value [,start|middle|end]
|
||||
} else if (name.equals("position")) {
|
||||
try {
|
||||
mCue.mTextPosition = parseIntPercentage(value);
|
||||
|
||||
Reference in New Issue
Block a user