From 0bffc3e4f32d49bd95ebc849c3244fe144d48b3d Mon Sep 17 00:00:00 2001 From: gedoor Date: Tue, 15 Sep 2020 22:38:50 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96=E6=90=9C=E7=B4=A2=E6=96=87?= =?UTF-8?q?=E5=AD=97=E9=A2=9C=E8=89=B2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../app/ui/book/searchContent/SearchResult.kt | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/app/src/main/java/io/legado/app/ui/book/searchContent/SearchResult.kt b/app/src/main/java/io/legado/app/ui/book/searchContent/SearchResult.kt index 6b0d9df5b..3a629839b 100644 --- a/app/src/main/java/io/legado/app/ui/book/searchContent/SearchResult.kt +++ b/app/src/main/java/io/legado/app/ui/book/searchContent/SearchResult.kt @@ -1,9 +1,11 @@ package io.legado.app.ui.book.searchContent import android.text.Spanned -import android.util.Log import androidx.core.text.HtmlCompat -import io.legado.app.ui.book.read.page.entities.TextPage +import io.legado.app.App +import io.legado.app.R +import io.legado.app.utils.getCompatColor +import io.legado.app.utils.hexString data class SearchResult( var index: Int = 0, @@ -23,12 +25,13 @@ data class SearchResult( "($chapterTitle)" } - fun colorPresentText(position: Int, center: String, targetText: String): String{ + fun colorPresentText(position: Int, center: String, targetText: String): String { val sub1 = text.substring(0, position) val sub2 = text.substring(position + center.length, targetText.length) - return "$sub1" + + val textColor = App.INSTANCE.getCompatColor(R.color.primaryText).hexString + return "$sub1" + "$center" + - "$sub2" + "$sub2" } fun parseText(targetText: String): Spanned {