Ellipsize chapters in feed

This commit is contained in:
Koitharu
2021-02-16 20:03:25 +02:00
parent ed70ca4e18
commit d9d5595bde
4 changed files with 42 additions and 24 deletions

View File

@@ -6,21 +6,37 @@ import org.koitharu.kotatsu.R
import org.koitharu.kotatsu.core.model.TrackingLogItem
import org.koitharu.kotatsu.utils.ext.formatRelative
fun TrackingLogItem.toFeedItem(resources: Resources) = FeedItem(
id = id,
imageUrl = manga.coverUrl,
title = manga.title,
subtitle = buildString {
append(createdAt.formatRelative(DateUtils.DAY_IN_MILLIS))
append(" ")
append(
resources.getQuantityString(
R.plurals.new_chapters,
chapters.size,
chapters.size
fun TrackingLogItem.toFeedItem(resources: Resources): FeedItem {
val chaptersString = if (chapters.size > MAX_CHAPTERS) {
chapters.joinToString(
separator = "\n",
limit = MAX_CHAPTERS - 1,
truncated = resources.getString(
R.string._and_x_more,
chapters.size - MAX_CHAPTERS + 1
)
)
},
chapters = chapters.joinToString("\n"),
manga = manga
)
} else {
chapters.joinToString("\n")
}
return FeedItem(
id = id,
imageUrl = manga.coverUrl,
title = manga.title,
subtitle = buildString {
append(createdAt.formatRelative(DateUtils.DAY_IN_MILLIS))
append(" ")
append(
resources.getQuantityString(
R.plurals.new_chapters,
chapters.size,
chapters.size
)
)
},
chapters = chaptersString,
manga = manga
)
}
private const val MAX_CHAPTERS = 6