Merge pull request #1860 from Xwite/master
feat:remove unnecessary code
This commit is contained in:
@@ -14,7 +14,6 @@ import io.legado.app.help.coroutine.Coroutine
|
|||||||
import io.legado.app.model.localBook.EpubFile
|
import io.legado.app.model.localBook.EpubFile
|
||||||
import io.legado.app.utils.BitmapUtils
|
import io.legado.app.utils.BitmapUtils
|
||||||
import io.legado.app.utils.FileUtils
|
import io.legado.app.utils.FileUtils
|
||||||
import io.legado.app.utils.isXml
|
|
||||||
import kotlinx.coroutines.Dispatchers.IO
|
import kotlinx.coroutines.Dispatchers.IO
|
||||||
import kotlinx.coroutines.withContext
|
import kotlinx.coroutines.withContext
|
||||||
import splitties.init.appCtx
|
import splitties.init.appCtx
|
||||||
@@ -93,8 +92,10 @@ object ImageProvider {
|
|||||||
op.inJustDecodeBounds = true
|
op.inJustDecodeBounds = true
|
||||||
BitmapFactory.decodeFile(file.absolutePath, op)
|
BitmapFactory.decodeFile(file.absolutePath, op)
|
||||||
if (op.outWidth < 1 && op.outHeight < 1) {
|
if (op.outWidth < 1 && op.outHeight < 1) {
|
||||||
putDebug("ImageProvider: delete file due to image size ${op.outHeight}*${op.outWidth}. path: ${file.absolutePath}")
|
Coroutine.async {
|
||||||
file.delete()
|
putDebug("ImageProvider: delete file due to image size ${op.outHeight}*${op.outWidth}. path: ${file.absolutePath}")
|
||||||
|
file.delete()
|
||||||
|
}
|
||||||
return Size(errorBitmap.width, errorBitmap.height)
|
return Size(errorBitmap.width, errorBitmap.height)
|
||||||
}
|
}
|
||||||
return Size(op.outWidth, op.outHeight)
|
return Size(op.outWidth, op.outHeight)
|
||||||
@@ -112,6 +113,7 @@ object ImageProvider {
|
|||||||
val cacheBitmap = bitmapLruCache.get(src)
|
val cacheBitmap = bitmapLruCache.get(src)
|
||||||
if (cacheBitmap != null) return cacheBitmap
|
if (cacheBitmap != null) return cacheBitmap
|
||||||
val vFile = BookHelp.getImage(book, src)
|
val vFile = BookHelp.getImage(book, src)
|
||||||
|
if (!vFile.exists()) return errorBitmap
|
||||||
@Suppress("BlockingMethodInNonBlockingContext")
|
@Suppress("BlockingMethodInNonBlockingContext")
|
||||||
return kotlin.runCatching {
|
return kotlin.runCatching {
|
||||||
val bitmap = BitmapUtils.decodeBitmap(vFile.absolutePath, width, height)
|
val bitmap = BitmapUtils.decodeBitmap(vFile.absolutePath, width, height)
|
||||||
@@ -119,16 +121,10 @@ object ImageProvider {
|
|||||||
bitmapLruCache.put(src, bitmap)
|
bitmapLruCache.put(src, bitmap)
|
||||||
bitmap
|
bitmap
|
||||||
}.onFailure {
|
}.onFailure {
|
||||||
Coroutine.async {
|
putDebug(
|
||||||
putDebug(
|
"ImageProvider: decode bitmap failed. path: ${vFile.absolutePath}\n$it",
|
||||||
"ImageProvider: decode bitmap failed. path: ${vFile.absolutePath}\n$it",
|
it
|
||||||
it
|
)
|
||||||
)
|
|
||||||
if (FileUtils.readText(vFile.absolutePath).isXml()) {
|
|
||||||
putDebug("ImageProvider: delete xml file. path: ${vFile.absolutePath}")
|
|
||||||
vFile.delete()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}.getOrDefault(errorBitmap)
|
}.getOrDefault(errorBitmap)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user