mirror of
https://github.com/mihonapp/mihon.git
synced 2024-11-21 20:47:03 -05:00
Remove reflection to get TextView color field (closes #2469)
This commit is contained in:
parent
044a4f7575
commit
5f2aaeac57
1 changed files with 2 additions and 10 deletions
|
@ -24,12 +24,12 @@ class PageIndicatorTextView(
|
|||
private val strokeColor = Color.rgb(45, 45, 45)
|
||||
|
||||
override fun onDraw(canvas: Canvas) {
|
||||
textColorField.set(this, strokeColor)
|
||||
setTextColor(strokeColor)
|
||||
paint.strokeWidth = 4f
|
||||
paint.style = Paint.Style.STROKE
|
||||
super.onDraw(canvas)
|
||||
|
||||
textColorField.set(this, fillColor)
|
||||
setTextColor(fillColor)
|
||||
paint.strokeWidth = 0f
|
||||
paint.style = Paint.Style.FILL
|
||||
super.onDraw(canvas)
|
||||
|
@ -50,12 +50,4 @@ class PageIndicatorTextView(
|
|||
|
||||
super.setText(finalText, TextView.BufferType.SPANNABLE)
|
||||
}
|
||||
|
||||
private companion object {
|
||||
// We need to use reflection to set the text color instead of using [setTextColor],
|
||||
// otherwise the view is invalidated inside [onDraw] and there's an infinite loop
|
||||
val textColorField = TextView::class.java.getDeclaredField("mCurTextColor").apply {
|
||||
isAccessible = true
|
||||
}!!
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue