mirror of
https://github.com/gedoor/legado.git
synced 2025-01-08 11:47:32 +08:00
优化
This commit is contained in:
parent
7af57714eb
commit
e4583fe206
@ -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)
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -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)
|
||||
}
|
||||
}
|
||||
|
@ -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) => {
|
||||
|
Loading…
Reference in New Issue
Block a user