@@ -10,38 +10,36 @@ class MarkSpan : CharacterStyle, IAztecInlineSpan {
10
10
override var TAG = " mark"
11
11
12
12
override var attributes: AztecAttributes = AztecAttributes ()
13
- var textColor : Int? = null
13
+ private val textColorValue : Int?
14
14
15
15
constructor (attributes: AztecAttributes = AztecAttributes ()) : super () {
16
16
this .attributes = attributes
17
17
18
18
val color = CssStyleFormatter .getStyleAttribute(attributes,
19
19
CssStyleFormatter .CSS_COLOR_ATTRIBUTE )
20
- if (color.isNotEmpty()) {
21
- textColor = Color .parseColor(color)
20
+ textColorValue = if (color.isNotEmpty()) {
21
+ Color .parseColor(color)
22
+ } else {
23
+ null
22
24
}
23
25
}
24
26
25
27
constructor (attributes: AztecAttributes = AztecAttributes (), colorString: String? ) : super () {
26
28
this .attributes = attributes
27
29
28
- if (colorString != null ) {
29
- textColor = Color .parseColor(colorString)
30
+ textColorValue = if (colorString != null ) {
31
+ Color .parseColor(colorString)
32
+ } else {
33
+ null
30
34
}
31
35
}
32
36
33
37
override fun updateDrawState (tp : TextPaint ) {
34
- configureTextPaint(tp)
35
- }
36
-
37
- private fun configureTextPaint (tp : TextPaint ) {
38
- if (textColor != null ) {
39
- tp.color = textColor as Int
40
- }
38
+ textColorValue?.let { tp.color = it }
41
39
}
42
40
43
41
fun getTextColor (): String {
44
- val currentColor = textColor ? : 0
42
+ val currentColor = textColorValue ? : 0
45
43
return String .format(" #%06X" , 0xFFFFFF and currentColor)
46
44
}
47
45
}
0 commit comments