This commit is contained in:
Horis 2024-09-19 12:57:45 +08:00
parent 7af57714eb
commit e4583fe206
3 changed files with 24 additions and 3 deletions

View File

@ -1,6 +1,7 @@
package io.legado.app.api.controller
import androidx.core.graphics.drawable.toBitmap
import com.bumptech.glide.Glide
import io.legado.app.api.ReturnData
import io.legado.app.data.appDb
import io.legado.app.data.entities.Book
@ -63,11 +64,21 @@ object BookController {
fun getCover(parameters: Map<String, List<String>>): ReturnData {
val returnData = ReturnData()
val coverPath = parameters["path"]?.firstOrNull()
val ftBitmap = ImageLoader.loadBitmap(appCtx, coverPath).submit()
val ftBitmap = ImageLoader.loadBitmap(appCtx, coverPath)
.override(84, 112)
.centerCrop()
.submit()
return try {
returnData.setData(ftBitmap.get())
} catch (e: Exception) {
returnData.setData(BookCover.defaultDrawable.toBitmap())
val defaultBitmap = Glide.with(appCtx)
.asBitmap()
.load(BookCover.defaultDrawable.toBitmap())
.override(84, 112)
.centerCrop()
.submit()
.get()
returnData.setData(defaultBitmap)
}
}

View File

@ -4,6 +4,8 @@ import android.annotation.SuppressLint
import android.os.Bundle
import android.view.View
import android.view.ViewGroup
import com.bumptech.glide.load.engine.DiskCacheStrategy
import com.bumptech.glide.load.resource.bitmap.DownsampleStrategy
import com.bumptech.glide.request.RequestOptions
import io.legado.app.R
import io.legado.app.base.BaseDialogFragment
@ -50,6 +52,9 @@ class PhotoDialog() : BaseDialogFragment(R.layout.dialog_photo_view) {
if (file?.exists() == true) {
ImageLoader.load(requireContext(), file)
.error(R.drawable.image_loading_error)
.dontTransform()
.downsample(DownsampleStrategy.NONE)
.diskCacheStrategy(DiskCacheStrategy.NONE)
.into(binding.photoView)
} else {
ImageLoader.load(requireContext(), src).apply {
@ -62,6 +67,8 @@ class PhotoDialog() : BaseDialogFragment(R.layout.dialog_photo_view) {
)
}
}.error(BookCover.defaultDrawable)
.dontTransform()
.downsample(DownsampleStrategy.NONE)
.into(binding.photoView)
}
}

View File

@ -186,7 +186,10 @@ const handleBookClick = async (book) => {
durChapterIndex = 0,
durChapterPos = 0,
} = book;
await API.saveBook(book);
// searchBook
if (book.durChapterIndex === undefined) {
await API.saveBook(book);
}
toDetail(bookUrl, name, author, durChapterIndex, durChapterPos);
};
const toDetail = (bookUrl, bookName, bookAuthor, chapterIndex, chapterPos) => {