File tree Expand file tree Collapse file tree 1 file changed +10
-7
lines changed
aztec/src/main/kotlin/org/wordpress/aztec/spans Expand file tree Collapse file tree 1 file changed +10
-7
lines changed Original file line number Diff line number Diff line change @@ -17,19 +17,22 @@ class MarkSpan : CharacterStyle, IAztecInlineSpan {
1717
1818 val color = CssStyleFormatter .getStyleAttribute(attributes,
1919 CssStyleFormatter .CSS_COLOR_ATTRIBUTE )
20- textColorValue = if (color.isNotEmpty()) {
21- Color .parseColor(color)
22- } else {
23- null
24- }
20+ textColorValue = safelyParseColor(color)
2521 }
2622
2723 constructor (attributes: AztecAttributes = AztecAttributes (), colorString: String? ) : super () {
2824 this .attributes = attributes
25+ textColorValue = safelyParseColor(colorString)
26+ }
2927
30- textColorValue = if (colorString != null ) {
28+ private fun safelyParseColor (colorString : String? ): Int? {
29+ if (colorString == null ) {
30+ return null
31+ }
32+ return try {
3133 Color .parseColor(colorString)
32- } else {
34+ } catch (e: IllegalArgumentException ) {
35+ // Unknown color
3336 null
3437 }
3538 }
You can’t perform that action at this time.
0 commit comments