com.google.android.exoplayer2.util.ColorParser Java Examples
The following examples show how to use
com.google.android.exoplayer2.util.ColorParser.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: Usernotes.java From Slide with GNU General Public License v3.0 | 5 votes |
/** * Get a color from a warning index * @param index Index * @return A color int */ @ColorInt public int getColorFromWarningIndex(int index) { String color = "#808080"; ToolboxConfig config = Toolbox.getConfig(subreddit); if (config != null) { // Subs can have usernotes without a toolbox config color = config.getUsernoteColor(constants.getTypeName(index)); } else { Map<String, String> defaults = Toolbox.DEFAULT_USERNOTE_TYPES.get(constants.getTypeName(index)); if (defaults != null) { String defaultColor = defaults.get("color"); if (defaultColor != null) { color = defaultColor; } } } try { return ColorParser.parseCssColor(color); } catch (IllegalArgumentException e) { return 0xFF808080; } }
Example #2
Source File: CssParser.java From MediaSDK with Apache License 2.0 | 4 votes |
private static void parseStyleDeclaration(ParsableByteArray input, WebvttCssStyle style, StringBuilder stringBuilder) { skipWhitespaceAndComments(input); String property = parseIdentifier(input, stringBuilder); if ("".equals(property)) { return; } if (!":".equals(parseNextToken(input, stringBuilder))) { return; } skipWhitespaceAndComments(input); String value = parsePropertyValue(input, stringBuilder); if (value == null || "".equals(value)) { return; } int position = input.getPosition(); String token = parseNextToken(input, stringBuilder); if (";".equals(token)) { // The style declaration is well formed. } else if (RULE_END.equals(token)) { // The style declaration is well formed and we can go on, but the closing bracket had to be // fed back. input.setPosition(position); } else { // The style declaration is not well formed. return; } // At this point we have a presumably valid declaration, we need to parse it and fill the style. if ("color".equals(property)) { style.setFontColor(ColorParser.parseCssColor(value)); } else if (PROPERTY_BGCOLOR.equals(property)) { style.setBackgroundColor(ColorParser.parseCssColor(value)); } else if (PROPERTY_TEXT_DECORATION.equals(property)) { if (VALUE_UNDERLINE.equals(value)) { style.setUnderline(true); } } else if (PROPERTY_FONT_FAMILY.equals(property)) { style.setFontFamily(value); } else if (PROPERTY_FONT_WEIGHT.equals(property)) { if (VALUE_BOLD.equals(value)) { style.setBold(true); } } else if (PROPERTY_FONT_STYLE.equals(property)) { if (VALUE_ITALIC.equals(value)) { style.setItalic(true); } } // TODO: Fill remaining supported styles. }
Example #3
Source File: CssParser.java From TelePlus-Android with GNU General Public License v2.0 | 4 votes |
private static void parseStyleDeclaration(ParsableByteArray input, WebvttCssStyle style, StringBuilder stringBuilder) { skipWhitespaceAndComments(input); String property = parseIdentifier(input, stringBuilder); if ("".equals(property)) { return; } if (!":".equals(parseNextToken(input, stringBuilder))) { return; } skipWhitespaceAndComments(input); String value = parsePropertyValue(input, stringBuilder); if (value == null || "".equals(value)) { return; } int position = input.getPosition(); String token = parseNextToken(input, stringBuilder); if (";".equals(token)) { // The style declaration is well formed. } else if (BLOCK_END.equals(token)) { // The style declaration is well formed and we can go on, but the closing bracket had to be // fed back. input.setPosition(position); } else { // The style declaration is not well formed. return; } // At this point we have a presumably valid declaration, we need to parse it and fill the style. if ("color".equals(property)) { style.setFontColor(ColorParser.parseCssColor(value)); } else if (PROPERTY_BGCOLOR.equals(property)) { style.setBackgroundColor(ColorParser.parseCssColor(value)); } else if (PROPERTY_TEXT_DECORATION.equals(property)) { if (VALUE_UNDERLINE.equals(value)) { style.setUnderline(true); } } else if (PROPERTY_FONT_FAMILY.equals(property)) { style.setFontFamily(value); } else if (PROPERTY_FONT_WEIGHT.equals(property)) { if (VALUE_BOLD.equals(value)) { style.setBold(true); } } else if (PROPERTY_FONT_STYLE.equals(property)) { if (VALUE_ITALIC.equals(value)) { style.setItalic(true); } } // TODO: Fill remaining supported styles. }
Example #4
Source File: CssParser.java From TelePlus-Android with GNU General Public License v2.0 | 4 votes |
private static void parseStyleDeclaration(ParsableByteArray input, WebvttCssStyle style, StringBuilder stringBuilder) { skipWhitespaceAndComments(input); String property = parseIdentifier(input, stringBuilder); if ("".equals(property)) { return; } if (!":".equals(parseNextToken(input, stringBuilder))) { return; } skipWhitespaceAndComments(input); String value = parsePropertyValue(input, stringBuilder); if (value == null || "".equals(value)) { return; } int position = input.getPosition(); String token = parseNextToken(input, stringBuilder); if (";".equals(token)) { // The style declaration is well formed. } else if (BLOCK_END.equals(token)) { // The style declaration is well formed and we can go on, but the closing bracket had to be // fed back. input.setPosition(position); } else { // The style declaration is not well formed. return; } // At this point we have a presumably valid declaration, we need to parse it and fill the style. if ("color".equals(property)) { style.setFontColor(ColorParser.parseCssColor(value)); } else if (PROPERTY_BGCOLOR.equals(property)) { style.setBackgroundColor(ColorParser.parseCssColor(value)); } else if (PROPERTY_TEXT_DECORATION.equals(property)) { if (VALUE_UNDERLINE.equals(value)) { style.setUnderline(true); } } else if (PROPERTY_FONT_FAMILY.equals(property)) { style.setFontFamily(value); } else if (PROPERTY_FONT_WEIGHT.equals(property)) { if (VALUE_BOLD.equals(value)) { style.setBold(true); } } else if (PROPERTY_FONT_STYLE.equals(property)) { if (VALUE_ITALIC.equals(value)) { style.setItalic(true); } } // TODO: Fill remaining supported styles. }
Example #5
Source File: CssParser.java From no-player with Apache License 2.0 | 4 votes |
private static void parseStyleDeclaration(ParsableByteArray input, WebvttCssStyle style, StringBuilder stringBuilder) { skipWhitespaceAndComments(input); String property = parseIdentifier(input, stringBuilder); if ("".equals(property)) { return; } if (!":".equals(parseNextToken(input, stringBuilder))) { return; } skipWhitespaceAndComments(input); String value = parsePropertyValue(input, stringBuilder); if (value == null || "".equals(value)) { return; } int position = input.getPosition(); String token = parseNextToken(input, stringBuilder); if (";".equals(token)) { // The style declaration is well formed. } else if (BLOCK_END.equals(token)) { // The style declaration is well formed and we can go on, but the closing bracket had to be // fed back. input.setPosition(position); } else { // The style declaration is not well formed. return; } // At this point we have a presumably valid declaration, we need to parse it and fill the style. if ("color".equals(property)) { style.setFontColor(ColorParser.parseCssColor(value)); } else if (PROPERTY_BGCOLOR.equals(property)) { style.setBackgroundColor(ColorParser.parseCssColor(value)); } else if (PROPERTY_TEXT_DECORATION.equals(property)) { if (VALUE_UNDERLINE.equals(value)) { style.setUnderline(true); } } else if (PROPERTY_FONT_FAMILY.equals(property)) { style.setFontFamily(value); } else if (PROPERTY_FONT_WEIGHT.equals(property)) { if (VALUE_BOLD.equals(value)) { style.setBold(true); } } else if (PROPERTY_FONT_STYLE.equals(property)) { if (VALUE_ITALIC.equals(value)) { style.setItalic(true); } } // TODO: Fill remaining supported styles. }
Example #6
Source File: CssParser.java From K-Sonic with MIT License | 4 votes |
private static void parseStyleDeclaration(ParsableByteArray input, WebvttCssStyle style, StringBuilder stringBuilder) { skipWhitespaceAndComments(input); String property = parseIdentifier(input, stringBuilder); if ("".equals(property)) { return; } if (!":".equals(parseNextToken(input, stringBuilder))) { return; } skipWhitespaceAndComments(input); String value = parsePropertyValue(input, stringBuilder); if (value == null || "".equals(value)) { return; } int position = input.getPosition(); String token = parseNextToken(input, stringBuilder); if (";".equals(token)) { // The style declaration is well formed. } else if (BLOCK_END.equals(token)) { // The style declaration is well formed and we can go on, but the closing bracket had to be // fed back. input.setPosition(position); } else { // The style declaration is not well formed. return; } // At this point we have a presumably valid declaration, we need to parse it and fill the style. if ("color".equals(property)) { style.setFontColor(ColorParser.parseCssColor(value)); } else if (PROPERTY_BGCOLOR.equals(property)) { style.setBackgroundColor(ColorParser.parseCssColor(value)); } else if (PROPERTY_TEXT_DECORATION.equals(property)) { if (VALUE_UNDERLINE.equals(value)) { style.setUnderline(true); } } else if (PROPERTY_FONT_FAMILY.equals(property)) { style.setFontFamily(value); } else if (PROPERTY_FONT_WEIGHT.equals(property)) { if (VALUE_BOLD.equals(value)) { style.setBold(true); } } else if (PROPERTY_FONT_STYLE.equals(property)) { if (VALUE_ITALIC.equals(value)) { style.setItalic(true); } } // TODO: Fill remaining supported styles. }
Example #7
Source File: CssParser.java From Telegram-FOSS with GNU General Public License v2.0 | 4 votes |
private static void parseStyleDeclaration(ParsableByteArray input, WebvttCssStyle style, StringBuilder stringBuilder) { skipWhitespaceAndComments(input); String property = parseIdentifier(input, stringBuilder); if ("".equals(property)) { return; } if (!":".equals(parseNextToken(input, stringBuilder))) { return; } skipWhitespaceAndComments(input); String value = parsePropertyValue(input, stringBuilder); if (value == null || "".equals(value)) { return; } int position = input.getPosition(); String token = parseNextToken(input, stringBuilder); if (";".equals(token)) { // The style declaration is well formed. } else if (RULE_END.equals(token)) { // The style declaration is well formed and we can go on, but the closing bracket had to be // fed back. input.setPosition(position); } else { // The style declaration is not well formed. return; } // At this point we have a presumably valid declaration, we need to parse it and fill the style. if ("color".equals(property)) { style.setFontColor(ColorParser.parseCssColor(value)); } else if (PROPERTY_BGCOLOR.equals(property)) { style.setBackgroundColor(ColorParser.parseCssColor(value)); } else if (PROPERTY_TEXT_DECORATION.equals(property)) { if (VALUE_UNDERLINE.equals(value)) { style.setUnderline(true); } } else if (PROPERTY_FONT_FAMILY.equals(property)) { style.setFontFamily(value); } else if (PROPERTY_FONT_WEIGHT.equals(property)) { if (VALUE_BOLD.equals(value)) { style.setBold(true); } } else if (PROPERTY_FONT_STYLE.equals(property)) { if (VALUE_ITALIC.equals(value)) { style.setItalic(true); } } // TODO: Fill remaining supported styles. }
Example #8
Source File: CssParser.java From Telegram with GNU General Public License v2.0 | 4 votes |
private static void parseStyleDeclaration(ParsableByteArray input, WebvttCssStyle style, StringBuilder stringBuilder) { skipWhitespaceAndComments(input); String property = parseIdentifier(input, stringBuilder); if ("".equals(property)) { return; } if (!":".equals(parseNextToken(input, stringBuilder))) { return; } skipWhitespaceAndComments(input); String value = parsePropertyValue(input, stringBuilder); if (value == null || "".equals(value)) { return; } int position = input.getPosition(); String token = parseNextToken(input, stringBuilder); if (";".equals(token)) { // The style declaration is well formed. } else if (RULE_END.equals(token)) { // The style declaration is well formed and we can go on, but the closing bracket had to be // fed back. input.setPosition(position); } else { // The style declaration is not well formed. return; } // At this point we have a presumably valid declaration, we need to parse it and fill the style. if ("color".equals(property)) { style.setFontColor(ColorParser.parseCssColor(value)); } else if (PROPERTY_BGCOLOR.equals(property)) { style.setBackgroundColor(ColorParser.parseCssColor(value)); } else if (PROPERTY_TEXT_DECORATION.equals(property)) { if (VALUE_UNDERLINE.equals(value)) { style.setUnderline(true); } } else if (PROPERTY_FONT_FAMILY.equals(property)) { style.setFontFamily(value); } else if (PROPERTY_FONT_WEIGHT.equals(property)) { if (VALUE_BOLD.equals(value)) { style.setBold(true); } } else if (PROPERTY_FONT_STYLE.equals(property)) { if (VALUE_ITALIC.equals(value)) { style.setItalic(true); } } // TODO: Fill remaining supported styles. }