mirror of
https://github.com/mihonapp/mihon.git
synced 2024-12-01 15:14:12 -05:00
Use DSL for creating chapter description spanned string
This commit is contained in:
parent
fba3f9d501
commit
6dbc0a6fd5
1 changed files with 6 additions and 4 deletions
|
@ -1,9 +1,9 @@
|
||||||
package eu.kanade.tachiyomi.ui.manga.chapter
|
package eu.kanade.tachiyomi.ui.manga.chapter
|
||||||
|
|
||||||
import android.text.SpannableString
|
|
||||||
import android.text.SpannableStringBuilder
|
import android.text.SpannableStringBuilder
|
||||||
import android.text.style.ForegroundColorSpan
|
|
||||||
import android.view.View
|
import android.view.View
|
||||||
|
import androidx.core.text.buildSpannedString
|
||||||
|
import androidx.core.text.color
|
||||||
import androidx.core.view.isVisible
|
import androidx.core.view.isVisible
|
||||||
import eu.kanade.tachiyomi.R
|
import eu.kanade.tachiyomi.R
|
||||||
import eu.kanade.tachiyomi.data.database.models.Manga
|
import eu.kanade.tachiyomi.data.database.models.Manga
|
||||||
|
@ -59,8 +59,10 @@ class ChapterHolder(
|
||||||
descriptions.add(adapter.dateFormat.format(Date(chapter.date_upload)))
|
descriptions.add(adapter.dateFormat.format(Date(chapter.date_upload)))
|
||||||
}
|
}
|
||||||
if (!chapter.read && chapter.last_page_read > 0) {
|
if (!chapter.read && chapter.last_page_read > 0) {
|
||||||
val lastPageRead = SpannableString(itemView.context.getString(R.string.chapter_progress, chapter.last_page_read + 1)).apply {
|
val lastPageRead = buildSpannedString {
|
||||||
setSpan(ForegroundColorSpan(adapter.readColor), 0, length, SpannableString.SPAN_EXCLUSIVE_EXCLUSIVE)
|
color(adapter.readColor) {
|
||||||
|
append(itemView.context.getString(R.string.chapter_progress, chapter.last_page_read + 1))
|
||||||
|
}
|
||||||
}
|
}
|
||||||
descriptions.add(lastPageRead)
|
descriptions.add(lastPageRead)
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue