diff --git a/app/src/main/java/io/legado/app/ui/book/read/PhotoDialog.kt b/app/src/main/java/io/legado/app/ui/book/read/PhotoDialog.kt index 635a24c6e..50eb3a9e5 100644 --- a/app/src/main/java/io/legado/app/ui/book/read/PhotoDialog.kt +++ b/app/src/main/java/io/legado/app/ui/book/read/PhotoDialog.kt @@ -5,9 +5,10 @@ import android.view.View import io.legado.app.R import io.legado.app.base.BaseDialogFragment import io.legado.app.databinding.DialogPhotoViewBinding +import io.legado.app.help.BookHelp +import io.legado.app.help.glide.ImageLoader import io.legado.app.model.BookCover import io.legado.app.model.ReadBook -import io.legado.app.ui.book.read.page.provider.ImageProvider import io.legado.app.utils.setLayout import io.legado.app.utils.viewbindingdelegate.viewBinding @@ -40,14 +41,12 @@ class PhotoDialog() : BaseDialogFragment(R.layout.dialog_photo_view) { arguments?.let { val path = it.getString("path") if (path.isNullOrEmpty()) { - val src = it.getString("src") ReadBook.book?.let { book -> - src?.let { - execute { - ImageProvider.getImage(book, src, ReadBook.bookSource) - }.onSuccess { bitmap -> - binding.photoView.setImageBitmap(bitmap) - } + it.getString("src")?.let { src -> + val file = BookHelp.getImage(book, src) + ImageLoader.load(requireContext(), file) + .error(R.drawable.image_loading_error) + .into(binding.photoView) } } } else { diff --git a/app/src/main/java/io/legado/app/ui/book/read/page/provider/ImageProvider.kt b/app/src/main/java/io/legado/app/ui/book/read/page/provider/ImageProvider.kt index a0a1bcc36..f39b883b5 100644 --- a/app/src/main/java/io/legado/app/ui/book/read/page/provider/ImageProvider.kt +++ b/app/src/main/java/io/legado/app/ui/book/read/page/provider/ImageProvider.kt @@ -94,29 +94,4 @@ object ImageProvider { } } - suspend fun getImage( - book: Book, - src: String, - bookSource: BookSource? - ): Bitmap { - return withContext(IO) { - val vFile = cacheImage(book, src, bookSource) - try { - @Suppress("BlockingMethodInNonBlockingContext") - ImageLoader.loadBitmap(appCtx, vFile.absolutePath) - .submit(ChapterProvider.visibleWidth, ChapterProvider.visibleHeight) - .get() - } catch (e: Exception) { - Coroutine.async { - putDebug("${vFile.absolutePath} 解码失败\n$e", e) - if (FileUtils.readText(vFile.absolutePath).isXml()) { - putDebug("${vFile.absolutePath}为xml,自动删除") - vFile.delete() - } - } - errorBitmap - } - } - } - }