Merge pull request #1777 from Xwite/master

fix:错误删除正文图片,图片解码大小未设置
pull/1778/head
kunfei 3 years ago committed by GitHub
commit 07d12c7153
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 22
      app/src/main/java/io/legado/app/ui/book/read/page/provider/ImageProvider.kt

@ -1,11 +1,8 @@
package io.legado.app.ui.book.read.page.provider
import android.graphics.Bitmap
import com.bumptech.glide.load.DataSource
import com.bumptech.glide.load.engine.GlideException
import com.bumptech.glide.request.RequestListener
import com.bumptech.glide.request.target.Target
import io.legado.app.R
import io.legado.app.constant.AppLog.putDebug
import io.legado.app.data.entities.Book
import io.legado.app.data.entities.BookSource
import io.legado.app.help.BookHelp
@ -14,6 +11,7 @@ import io.legado.app.help.glide.ImageLoader
import io.legado.app.model.localBook.EpubFile
import io.legado.app.utils.FileUtils
import io.legado.app.utils.BitmapUtils
import io.legado.app.utils.isXml
import kotlinx.coroutines.runBlocking
import splitties.init.appCtx
import java.io.File
@ -52,12 +50,18 @@ object ImageProvider {
}
}
return try {
ImageLoader.loadBitmap(appCtx, vFile.absolutePath).submit().get()
ImageLoader.loadBitmap(appCtx, vFile.absolutePath)
.submit(ChapterProvider.visibleWidth,ChapterProvider.visibleHeight)
.get()
} catch (e: Exception) {
Coroutine.async { vFile.delete() }
//must call this method on a background thread
//ImageLoader.loadBitmap(appCtx, R.drawable.image_loading_error).submit().get()
errorBitmap
Coroutine.async {
putDebug("${vFile.absolutePath} 解码失败", e)
if (FileUtils.readText(vFile.absolutePath).isXml()) {
putDebug("${vFile.absolutePath}为xml,自动删除")
vFile.delete()
}
}
errorBitmap
}
}

Loading…
Cancel
Save