Use indirect image url in bookmarks
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
package org.koitharu.kotatsu.bookmarks.domain
|
||||
|
||||
import org.koitharu.kotatsu.parsers.model.Manga
|
||||
import org.koitharu.kotatsu.parsers.model.MangaPage
|
||||
import java.util.Date
|
||||
|
||||
class Bookmark(
|
||||
@@ -14,6 +15,20 @@ class Bookmark(
|
||||
val percent: Float,
|
||||
) {
|
||||
|
||||
val directImageUrl: String?
|
||||
get() = if (isImageUrlDirect()) imageUrl else null
|
||||
|
||||
fun toMangaPage() = MangaPage(
|
||||
id = pageId,
|
||||
url = imageUrl,
|
||||
preview = null,
|
||||
source = manga.source,
|
||||
)
|
||||
|
||||
private fun isImageUrlDirect(): Boolean {
|
||||
return imageUrl.substringAfterLast('.').length in 2..4
|
||||
}
|
||||
|
||||
override fun equals(other: Any?): Boolean {
|
||||
if (this === other) return true
|
||||
if (javaClass != other?.javaClass) return false
|
||||
|
||||
@@ -28,7 +28,8 @@ fun bookmarkListAD(
|
||||
binding.root.setOnLongClickListener(listener)
|
||||
|
||||
bind {
|
||||
binding.imageViewThumb.newImageRequest(lifecycleOwner, item.imageUrl)?.run {
|
||||
val data: Any = item.directImageUrl ?: item.toMangaPage()
|
||||
binding.imageViewThumb.newImageRequest(lifecycleOwner, data)?.run {
|
||||
size(CoverSizeResolver(binding.imageViewThumb))
|
||||
placeholder(R.drawable.ic_placeholder)
|
||||
fallback(R.drawable.ic_placeholder)
|
||||
|
||||
Reference in New Issue
Block a user