From 6dbc0a6fd50f0b97a0798792d482aa6657a7ea11 Mon Sep 17 00:00:00 2001 From: arkon Date: Sat, 17 Apr 2021 11:06:30 -0400 Subject: [PATCH] Use DSL for creating chapter description spanned string --- .../kanade/tachiyomi/ui/manga/chapter/ChapterHolder.kt | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/manga/chapter/ChapterHolder.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/manga/chapter/ChapterHolder.kt index e37a44eb3..789d6a75c 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/manga/chapter/ChapterHolder.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/manga/chapter/ChapterHolder.kt @@ -1,9 +1,9 @@ package eu.kanade.tachiyomi.ui.manga.chapter -import android.text.SpannableString import android.text.SpannableStringBuilder -import android.text.style.ForegroundColorSpan import android.view.View +import androidx.core.text.buildSpannedString +import androidx.core.text.color import androidx.core.view.isVisible import eu.kanade.tachiyomi.R import eu.kanade.tachiyomi.data.database.models.Manga @@ -59,8 +59,10 @@ class ChapterHolder( descriptions.add(adapter.dateFormat.format(Date(chapter.date_upload))) } if (!chapter.read && chapter.last_page_read > 0) { - val lastPageRead = SpannableString(itemView.context.getString(R.string.chapter_progress, chapter.last_page_read + 1)).apply { - setSpan(ForegroundColorSpan(adapter.readColor), 0, length, SpannableString.SPAN_EXCLUSIVE_EXCLUSIVE) + val lastPageRead = buildSpannedString { + color(adapter.readColor) { + append(itemView.context.getString(R.string.chapter_progress, chapter.last_page_read + 1)) + } } descriptions.add(lastPageRead) }