From f715478070393f57d847b010f941cbd2d87adece Mon Sep 17 00:00:00 2001 From: arkon Date: Thu, 9 Jan 2020 21:51:34 -0500 Subject: [PATCH] Revert "Remove reflection to get TextView color field (closes #2469)" This reverts commit 5f2aaeac575548a1984bb256c0150b7fcb0e2f2d. --- .../tachiyomi/ui/reader/PageIndicatorTextView.kt | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/reader/PageIndicatorTextView.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/reader/PageIndicatorTextView.kt index c467ce0db0..a938039720 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/reader/PageIndicatorTextView.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/reader/PageIndicatorTextView.kt @@ -24,12 +24,12 @@ class PageIndicatorTextView( private val strokeColor = Color.rgb(45, 45, 45) override fun onDraw(canvas: Canvas) { - setTextColor(strokeColor) + textColorField.set(this, strokeColor) paint.strokeWidth = 4f paint.style = Paint.Style.STROKE super.onDraw(canvas) - setTextColor(fillColor) + textColorField.set(this, fillColor) paint.strokeWidth = 0f paint.style = Paint.Style.FILL super.onDraw(canvas) @@ -50,4 +50,12 @@ 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 + }!! + } }