refactor LibraryCategoryAdapter scroll text logic

This commit is contained in:
Jays2Kings 2022-08-20 22:52:10 -04:00
parent 238b21c2e2
commit 17138d2b68

View file

@ -200,21 +200,13 @@ class LibraryCategoryAdapter(val controller: LibraryController?) :
val id = item.manga.id ?: return "" val id = item.manga.id ?: return ""
val history = db.getChapters(id).executeAsBlocking() val history = db.getChapters(id).executeAsBlocking()
val last = history.maxOfOrNull { it.date_fetch } val last = history.maxOfOrNull { it.date_fetch }
if (last != null && last > 100) { context.timeSpanFromNow(R.string.fetched_, last ?: 0)
context.timeSpanFromNow(R.string.fetched_, last)
} else {
"N/A"
}
} }
LibrarySort.LastRead -> { LibrarySort.LastRead -> {
val id = item.manga.id ?: return "" val id = item.manga.id ?: return ""
val history = db.getHistoryByMangaId(id).executeAsBlocking() val history = db.getHistoryByMangaId(id).executeAsBlocking()
val last = history.maxOfOrNull { it.last_read } val last = history.maxOfOrNull { it.last_read }
if (last != null && last > 100) { context.timeSpanFromNow(R.string.read_, last ?: 0)
context.timeSpanFromNow(R.string.read_, last)
} else {
"N/A"
}
} }
LibrarySort.Unread -> { LibrarySort.Unread -> {
val unread = item.manga.unread val unread = item.manga.unread
@ -233,20 +225,10 @@ class LibraryCategoryAdapter(val controller: LibraryController?) :
} }
} }
LibrarySort.LatestChapter -> { LibrarySort.LatestChapter -> {
val lastUpdate = item.manga.last_update context.timeSpanFromNow(R.string.updated_, item.manga.last_update)
if (lastUpdate > 0) {
context.timeSpanFromNow(R.string.updated_, lastUpdate)
} else {
"N/A"
}
} }
LibrarySort.DateAdded -> { LibrarySort.DateAdded -> {
val added = item.manga.date_added context.timeSpanFromNow(R.string.added_, item.manga.date_added)
if (added > 0) {
context.timeSpanFromNow(R.string.added_, added)
} else {
"N/A"
}
} }
LibrarySort.Title -> { LibrarySort.Title -> {
val title = if (preferences.removeArticles().get()) { val title = if (preferences.removeArticles().get()) {