Updating wording on the bubble of the fast scroll

Using "Read...", "Updated...", "Added..." for categories sorted that way
This commit is contained in:
Jay 2020-05-09 23:02:33 -04:00
parent b3fbe31c8d
commit 60c3f24515

View file

@ -116,21 +116,23 @@ class LibraryCategoryAdapter(val controller: LibraryController) :
val db: DatabaseHelper by injectLazy() val db: DatabaseHelper by injectLazy()
if (position == itemCount - 1) return recyclerView.context.getString(R.string.bottom) if (position == itemCount - 1) return recyclerView.context.getString(R.string.bottom)
return when (val item: IFlexible<*>? = getItem(position)) { return when (val item: IFlexible<*>? = getItem(position)) {
is LibraryHeaderItem -> is LibraryHeaderItem -> if (!preferences.hideCategories().getOrDefault()) {
if (!preferences.hideCategories().getOrDefault()) item.category.name item.category.name
else recyclerView.context.getString(R.string.top) } else {
recyclerView.context.getString(R.string.top)
}
is LibraryItem -> { is LibraryItem -> {
val text = if (item.manga.isBlank()) return item.header?.category?.name.orEmpty() val text = if (item.manga.isBlank()) return item.header?.category?.name.orEmpty()
else when (getSort(position)) { else when (getSort(position)) {
LibrarySort.DRAG_AND_DROP -> { LibrarySort.DRAG_AND_DROP -> {
if (!preferences.hideCategories().getOrDefault()) { if (!preferences.hideCategories().getOrDefault()) {
val title = item.manga.title val title = item.manga.title
if (preferences.removeArticles().getOrDefault()) if (preferences.removeArticles().getOrDefault()) title.removeArticles()
title.removeArticles().chop(15) .chop(15)
else title.take(10) else title.take(10)
} else { } else {
val category = db.getCategoriesForManga(item.manga) val category = db.getCategoriesForManga(item.manga).executeAsBlocking()
.executeAsBlocking().firstOrNull()?.name .firstOrNull()?.name
category ?: recyclerView.context.getString(R.string.default_value) category ?: recyclerView.context.getString(R.string.default_value)
} }
} }
@ -138,8 +140,13 @@ class LibraryCategoryAdapter(val controller: LibraryController) :
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.maxBy { it.last_read } val last = history.maxBy { it.last_read }
if (last != null && last.last_read > 100) last.last_read.timeSpanFromNow if (last != null && last.last_read > 100) {
else "N/A" recyclerView.context.getString(
R.string.read_, last.last_read.timeSpanFromNow
)
} else {
"N/A"
}
} }
LibrarySort.UNREAD -> { LibrarySort.UNREAD -> {
val unread = item.manga.unread val unread = item.manga.unread
@ -148,25 +155,37 @@ class LibraryCategoryAdapter(val controller: LibraryController) :
} }
LibrarySort.TOTAL -> { LibrarySort.TOTAL -> {
val total = item.chapterCount val total = item.chapterCount
if (total > 0) recyclerView.resources.getQuantityString(R.plurals if (total > 0) recyclerView.resources.getQuantityString(
.chapters, total, total) R.plurals.chapters, total, total
else "N/A" )
else {
"N/A"
}
} }
LibrarySort.LATEST_CHAPTER -> { LibrarySort.LATEST_CHAPTER -> {
val lastUpdate = item.manga.last_update val lastUpdate = item.manga.last_update
if (lastUpdate > 0) lastUpdate.timeSpanFromNow if (lastUpdate > 0) {
else "N/A" recyclerView.context.getString(
R.string.updated_, lastUpdate.timeSpanFromNow
)
} else {
"N/A"
}
} }
LibrarySort.DATE_ADDED -> { LibrarySort.DATE_ADDED -> {
val lastUpdate = item.manga.date_added val added = item.manga.date_added
if (lastUpdate > 0) lastUpdate.timeSpanFromNow if (added > 0) {
else "N/A" recyclerView.context.getString(R.string.added_, added.timeSpanFromNow)
} else {
"N/A"
}
} }
else -> { else -> {
val title = if (preferences.removeArticles() val title = if (preferences.removeArticles().getOrDefault()) {
.getOrDefault() item.manga.title.removeArticles()
) item.manga.title.removeArticles() } else {
else item.manga.title item.manga.title
}
getFirstLetter(title) getFirstLetter(title)
} }
} }