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 coil.target.ImageViewTarget
|
||||||
import eu.kanade.tachiyomi.data.cache.CoverCache
|
import eu.kanade.tachiyomi.data.cache.CoverCache
|
||||||
import eu.kanade.tachiyomi.data.database.models.Manga
|
import eu.kanade.tachiyomi.data.database.models.Manga
|
||||||
|
import eu.kanade.tachiyomi.util.system.launchIO
|
||||||
import uy.kohesive.injekt.injectLazy
|
import uy.kohesive.injekt.injectLazy
|
||||||
|
|
||||||
class LibraryMangaImageTarget(
|
class LibraryMangaImageTarget(
|
||||||
|
@ -37,15 +38,17 @@ class LibraryMangaImageTarget(
|
||||||
override fun onError(error: Drawable?) {
|
override fun onError(error: Drawable?) {
|
||||||
super.onError(error)
|
super.onError(error)
|
||||||
if (manga.favorite) {
|
if (manga.favorite) {
|
||||||
val file = coverCache.getCoverFile(manga)
|
launchIO {
|
||||||
// if the file exists and the there was still an error then the file is corrupted
|
val file = coverCache.getCoverFile(manga)
|
||||||
if (file.exists()) {
|
// if the file exists and the there was still an error then the file is corrupted
|
||||||
val options = BitmapFactory.Options()
|
if (file.exists()) {
|
||||||
options.inJustDecodeBounds = true
|
val options = BitmapFactory.Options()
|
||||||
BitmapFactory.decodeFile(file.path, options)
|
options.inJustDecodeBounds = true
|
||||||
if (options.outWidth == -1 || options.outHeight == -1) {
|
BitmapFactory.decodeFile(file.path, options)
|
||||||
file.delete()
|
if (options.outWidth == -1 || options.outHeight == -1) {
|
||||||
view.context.imageLoader.memoryCache.remove(MemoryCache.Key(manga.key()))
|
file.delete()
|
||||||
|
view.context.imageLoader.memoryCache.remove(MemoryCache.Key(manga.key()))
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -84,17 +84,8 @@ class LibraryGridHolder(
|
||||||
setSelected(adapter.isSelected(flexibleAdapterPosition))
|
setSelected(adapter.isSelected(flexibleAdapterPosition))
|
||||||
|
|
||||||
// Update the cover.
|
// Update the cover.
|
||||||
if (item.manga.thumbnail_url == null) binding.coverThumbnail.clear()
|
binding.coverThumbnail.clear()
|
||||||
else {
|
setCover(item.manga)
|
||||||
if (binding.coverThumbnail.height == 0) {
|
|
||||||
val oldPos = flexibleAdapterPosition
|
|
||||||
adapter.recyclerView.post {
|
|
||||||
if (oldPos == flexibleAdapterPosition) {
|
|
||||||
setCover(item.manga)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} else setCover(item.manga)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun toggleActivation() {
|
override fun toggleActivation() {
|
||||||
|
|
|
@ -70,14 +70,15 @@ class LibraryListHolder(
|
||||||
setUnreadBadge(binding.unreadDownloadBadge.badgeView, item)
|
setUnreadBadge(binding.unreadDownloadBadge.badgeView, item)
|
||||||
setCards(adapter.showOutline, binding.card, binding.unreadDownloadBadge.badgeView)
|
setCards(adapter.showOutline, binding.card, binding.unreadDownloadBadge.badgeView)
|
||||||
|
|
||||||
val authorArtist = if (item.manga.author == item.manga.artist || item.manga.artist.isNullOrBlank()) {
|
val authorArtist =
|
||||||
item.manga.author?.trim() ?: ""
|
if (item.manga.author == item.manga.artist || item.manga.artist.isNullOrBlank()) {
|
||||||
} else {
|
item.manga.author?.trim() ?: ""
|
||||||
listOfNotNull(
|
} else {
|
||||||
item.manga.author?.trim()?.takeIf { it.isNotBlank() },
|
listOfNotNull(
|
||||||
item.manga.artist?.trim()?.takeIf { it.isNotBlank() }
|
item.manga.author?.trim()?.takeIf { it.isNotBlank() },
|
||||||
).joinToString(", ")
|
item.manga.artist?.trim()?.takeIf { it.isNotBlank() }
|
||||||
}
|
).joinToString(", ")
|
||||||
|
}
|
||||||
|
|
||||||
binding.subtitle.text = authorArtist.highlightText(item.filter, color)
|
binding.subtitle.text = authorArtist.highlightText(item.filter, color)
|
||||||
binding.title.maxLines = 2
|
binding.title.maxLines = 2
|
||||||
|
@ -89,12 +90,8 @@ class LibraryListHolder(
|
||||||
}
|
}
|
||||||
|
|
||||||
// Update the cover.
|
// Update the cover.
|
||||||
if (item.manga.thumbnail_url == null) {
|
binding.coverThumbnail.clear()
|
||||||
binding.coverThumbnail.clear()
|
binding.coverThumbnail.loadManga(item.manga)
|
||||||
} else {
|
|
||||||
item.manga.id ?: return
|
|
||||||
binding.coverThumbnail.loadManga(item.manga)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onActionStateChanged(position: Int, actionState: Int) {
|
override fun onActionStateChanged(position: Int, actionState: Int) {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue