|
|
|
|
@ -1,6 +1,7 @@
|
|
|
|
|
package org.koitharu.kotatsu.details.ui.model
|
|
|
|
|
|
|
|
|
|
import android.text.format.DateUtils
|
|
|
|
|
import org.jsoup.internal.StringUtil.StringJoiner
|
|
|
|
|
import org.koitharu.kotatsu.list.ui.model.ListModel
|
|
|
|
|
import org.koitharu.kotatsu.parsers.model.MangaChapter
|
|
|
|
|
|
|
|
|
|
@ -10,6 +11,14 @@ data class ChapterListItem(
|
|
|
|
|
private val uploadDateMs: Long,
|
|
|
|
|
) : ListModel {
|
|
|
|
|
|
|
|
|
|
var description: String? = null
|
|
|
|
|
private set
|
|
|
|
|
get() {
|
|
|
|
|
if (field != null) return field
|
|
|
|
|
field = buildDescription()
|
|
|
|
|
return field
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
var uploadDate: CharSequence? = null
|
|
|
|
|
private set
|
|
|
|
|
get() {
|
|
|
|
|
@ -38,14 +47,20 @@ data class ChapterListItem(
|
|
|
|
|
val isNew: Boolean
|
|
|
|
|
get() = hasFlag(FLAG_NEW)
|
|
|
|
|
|
|
|
|
|
fun description(): CharSequence {
|
|
|
|
|
val number = chapter.number.toString()
|
|
|
|
|
val scanlator = chapter.scanlator?.takeUnless { it.isBlank() }
|
|
|
|
|
return when {
|
|
|
|
|
uploadDate != null && scanlator != null -> "#$number • $uploadDate • $scanlator"
|
|
|
|
|
scanlator != null -> "#$number • $scanlator"
|
|
|
|
|
else -> "#$number • $uploadDate"
|
|
|
|
|
private fun buildDescription(): String {
|
|
|
|
|
val joiner = StringJoiner(" • ")
|
|
|
|
|
if (chapter.number != 0) {
|
|
|
|
|
joiner.add("#").append(chapter.number.toString())
|
|
|
|
|
}
|
|
|
|
|
uploadDate?.let { date ->
|
|
|
|
|
joiner.add(date.toString())
|
|
|
|
|
}
|
|
|
|
|
chapter.scanlator?.let { scanlator ->
|
|
|
|
|
if (scanlator.isNotBlank()) {
|
|
|
|
|
joiner.add(scanlator)
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return joiner.complete()
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private fun hasFlag(flag: Int): Boolean {
|
|
|
|
|
|