Passes text color instead of context

This commit is contained in:
Benoit Marty 2019-10-29 15:51:18 +01:00
parent 42e0d0f769
commit 86667a6d8a

View file

@ -16,29 +16,26 @@
package im.vector.riotx.features.html
import android.content.Context
import android.graphics.Color
import android.text.TextPaint
import android.text.style.ClickableSpan
import android.view.View
import im.vector.riotx.R
import im.vector.riotx.features.themes.ThemeUtils
class SpoilerSpan(val bgColor: Int, val context: Context) : ClickableSpan() {
class SpoilerSpan(private val bgColor: Int, private val textColor: Int) : ClickableSpan() {
override fun onClick(widget: View) {
isHidden = !isHidden
widget.invalidate()
}
var isHidden = true
private var isHidden = true
override fun updateDrawState(tp: TextPaint) {
tp.bgColor = bgColor
if (isHidden) {
tp.color = Color.TRANSPARENT
} else {
tp.color = ThemeUtils.getColor(context, R.attr.riotx_text_primary)
tp.color = textColor
}
}
}