mirror of
https://github.com/null2264/yokai.git
synced 2025-06-21 10:44:42 +00:00
small optimizations to scrolling in library
This commit is contained in:
parent
9073e90ba0
commit
28da0b88ae
3 changed files with 25 additions and 34 deletions
|
@ -13,6 +13,7 @@ import coil.request.ImageRequest
|
|||
import coil.target.ImageViewTarget
|
||||
import eu.kanade.tachiyomi.data.cache.CoverCache
|
||||
import eu.kanade.tachiyomi.data.database.models.Manga
|
||||
import eu.kanade.tachiyomi.util.system.launchIO
|
||||
import uy.kohesive.injekt.injectLazy
|
||||
|
||||
class LibraryMangaImageTarget(
|
||||
|
@ -37,15 +38,17 @@ class LibraryMangaImageTarget(
|
|||
override fun onError(error: Drawable?) {
|
||||
super.onError(error)
|
||||
if (manga.favorite) {
|
||||
val file = coverCache.getCoverFile(manga)
|
||||
// if the file exists and the there was still an error then the file is corrupted
|
||||
if (file.exists()) {
|
||||
val options = BitmapFactory.Options()
|
||||
options.inJustDecodeBounds = true
|
||||
BitmapFactory.decodeFile(file.path, options)
|
||||
if (options.outWidth == -1 || options.outHeight == -1) {
|
||||
file.delete()
|
||||
view.context.imageLoader.memoryCache.remove(MemoryCache.Key(manga.key()))
|
||||
launchIO {
|
||||
val file = coverCache.getCoverFile(manga)
|
||||
// if the file exists and the there was still an error then the file is corrupted
|
||||
if (file.exists()) {
|
||||
val options = BitmapFactory.Options()
|
||||
options.inJustDecodeBounds = true
|
||||
BitmapFactory.decodeFile(file.path, options)
|
||||
if (options.outWidth == -1 || options.outHeight == -1) {
|
||||
file.delete()
|
||||
view.context.imageLoader.memoryCache.remove(MemoryCache.Key(manga.key()))
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -84,17 +84,8 @@ class LibraryGridHolder(
|
|||
setSelected(adapter.isSelected(flexibleAdapterPosition))
|
||||
|
||||
// Update the cover.
|
||||
if (item.manga.thumbnail_url == null) binding.coverThumbnail.clear()
|
||||
else {
|
||||
if (binding.coverThumbnail.height == 0) {
|
||||
val oldPos = flexibleAdapterPosition
|
||||
adapter.recyclerView.post {
|
||||
if (oldPos == flexibleAdapterPosition) {
|
||||
setCover(item.manga)
|
||||
}
|
||||
}
|
||||
} else setCover(item.manga)
|
||||
}
|
||||
binding.coverThumbnail.clear()
|
||||
setCover(item.manga)
|
||||
}
|
||||
|
||||
override fun toggleActivation() {
|
||||
|
|
|
@ -70,14 +70,15 @@ class LibraryListHolder(
|
|||
setUnreadBadge(binding.unreadDownloadBadge.badgeView, item)
|
||||
setCards(adapter.showOutline, binding.card, binding.unreadDownloadBadge.badgeView)
|
||||
|
||||
val authorArtist = if (item.manga.author == item.manga.artist || item.manga.artist.isNullOrBlank()) {
|
||||
item.manga.author?.trim() ?: ""
|
||||
} else {
|
||||
listOfNotNull(
|
||||
item.manga.author?.trim()?.takeIf { it.isNotBlank() },
|
||||
item.manga.artist?.trim()?.takeIf { it.isNotBlank() }
|
||||
).joinToString(", ")
|
||||
}
|
||||
val authorArtist =
|
||||
if (item.manga.author == item.manga.artist || item.manga.artist.isNullOrBlank()) {
|
||||
item.manga.author?.trim() ?: ""
|
||||
} else {
|
||||
listOfNotNull(
|
||||
item.manga.author?.trim()?.takeIf { it.isNotBlank() },
|
||||
item.manga.artist?.trim()?.takeIf { it.isNotBlank() }
|
||||
).joinToString(", ")
|
||||
}
|
||||
|
||||
binding.subtitle.text = authorArtist.highlightText(item.filter, color)
|
||||
binding.title.maxLines = 2
|
||||
|
@ -89,12 +90,8 @@ class LibraryListHolder(
|
|||
}
|
||||
|
||||
// Update the cover.
|
||||
if (item.manga.thumbnail_url == null) {
|
||||
binding.coverThumbnail.clear()
|
||||
} else {
|
||||
item.manga.id ?: return
|
||||
binding.coverThumbnail.loadManga(item.manga)
|
||||
}
|
||||
binding.coverThumbnail.clear()
|
||||
binding.coverThumbnail.loadManga(item.manga)
|
||||
}
|
||||
|
||||
override fun onActionStateChanged(position: Int, actionState: Int) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue