Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
SDK
/
exoplayer
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Snippets
Settings
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit
7974a614
authored
Jan 15, 2016
by
Oliver Woodman
Browse files
Options
_('Browse Files')
Download
Email Patches
Plain Diff
Fix TtmlColorParser test.
Also simplify the implementation slightly.
parent
afafd083
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
8 additions
and
9 deletions
library/src/androidTest/java/com/google/android/exoplayer/text/ttml/TtmlColorParserTest.java
library/src/main/java/com/google/android/exoplayer/text/ttml/TtmlColorParser.java
library/src/androidTest/java/com/google/android/exoplayer/text/ttml/TtmlColorParserTest.java
View file @
7974a614
...
...
@@ -24,10 +24,12 @@ import android.test.InstrumentationTestCase;
public
class
TtmlColorParserTest
extends
InstrumentationTestCase
{
public
void
testHexCodeParsing
()
{
assertEquals
(
Color
.
WHITE
,
TtmlColorParser
.
parseColor
(
"#ffffff"
));
assertEquals
(
Color
.
WHITE
,
TtmlColorParser
.
parseColor
(
"#ffffffff"
));
assertEquals
(
Color
.
parseColor
(
"#00ffffff"
),
TtmlColorParser
.
parseColor
(
"#00ffffff"
));
assertEquals
(
Color
.
parseColor
(
"#12341234"
),
TtmlColorParser
.
parseColor
(
"#12341234"
));
assertEquals
(
Color
.
WHITE
,
TtmlColorParser
.
parseColor
(
"#FFFFFF"
));
assertEquals
(
Color
.
WHITE
,
TtmlColorParser
.
parseColor
(
"#FFFFFFFF"
));
assertEquals
(
Color
.
parseColor
(
"#FF123456"
),
TtmlColorParser
.
parseColor
(
"#123456"
));
// Hex colors in TTML are RGBA, where-as {@link Color#parseColor} takes ARGB.
assertEquals
(
Color
.
parseColor
(
"#00FFFFFF"
),
TtmlColorParser
.
parseColor
(
"#FFFFFF00"
));
assertEquals
(
Color
.
parseColor
(
"#78123456"
),
TtmlColorParser
.
parseColor
(
"#12345678"
));
}
public
void
testColorNameParsing
()
{
...
...
library/src/main/java/com/google/android/exoplayer/text/ttml/TtmlColorParser.java
View file @
7974a614
...
...
@@ -40,7 +40,6 @@ import java.util.regex.Pattern;
private
static
final
Pattern
RGBA_PATTERN
=
Pattern
.
compile
(
"^rgba\\((\\d{1,3}),(\\d{1,3}),(\\d{1,3}),(\\d{1,3})\\)$"
);
static
final
int
TRANSPARENT
=
0x00000000
;
static
final
int
BLACK
=
0xFF000000
;
static
final
int
SILVER
=
0xFFC0C0C0
;
...
...
@@ -93,12 +92,10 @@ import java.util.regex.Pattern;
long
color
=
Long
.
parseLong
(
colorExpression
.
substring
(
1
),
16
);
if
(
colorExpression
.
length
()
==
7
)
{
// Set the alpha value
color
|=
0x
00000000FF000000
;
color
|=
0x
FF000000
L
;
}
else
if
(
colorExpression
.
length
()
==
9
)
{
// We have #RRGGBBAA, but we need #AARRGGBB
int
alpha
=
(
int
)
color
&
0x00000000000000FF
;
color
>>=
8
;
color
|=
alpha
<<
24
;
color
=
((
color
&
0xFF
)
<<
24
)
|
(
color
>>
8
);
}
else
{
throw
new
IllegalArgumentException
();
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment