优化
This commit is contained in:
@@ -89,7 +89,7 @@ object BookController {
|
|||||||
this.bookUrl = bookUrl
|
this.bookUrl = bookUrl
|
||||||
val bitmap = runBlocking {
|
val bitmap = runBlocking {
|
||||||
ImageProvider.cacheImage(book, src, bookSource)
|
ImageProvider.cacheImage(book, src, bookSource)
|
||||||
ImageProvider.getImage(book, src, width, bookSource = bookSource)
|
ImageProvider.getImage(book, src, width)
|
||||||
}
|
}
|
||||||
return returnData.setData(bitmap)
|
return returnData.setData(bitmap)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -170,8 +170,7 @@ class ContentTextView(context: Context, attrs: AttributeSet?) : View(context, at
|
|||||||
book,
|
book,
|
||||||
textChar.charData,
|
textChar.charData,
|
||||||
(textChar.end - textChar.start).toInt(),
|
(textChar.end - textChar.start).toInt(),
|
||||||
(lineBottom - lineTop).toInt(),
|
(lineBottom - lineTop).toInt()
|
||||||
ReadBook.bookSource
|
|
||||||
)
|
)
|
||||||
val rectF = if (textLine.isImage) {
|
val rectF = if (textLine.isImage) {
|
||||||
RectF(textChar.start, lineTop, textChar.end, lineBottom)
|
RectF(textChar.start, lineTop, textChar.end, lineBottom)
|
||||||
|
|||||||
@@ -16,7 +16,6 @@ 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 io.legado.app.utils.isXml
|
||||||
import kotlinx.coroutines.Dispatchers.IO
|
import kotlinx.coroutines.Dispatchers.IO
|
||||||
import kotlinx.coroutines.runBlocking
|
|
||||||
import kotlinx.coroutines.withContext
|
import kotlinx.coroutines.withContext
|
||||||
import splitties.init.appCtx
|
import splitties.init.appCtx
|
||||||
import java.io.File
|
import java.io.File
|
||||||
@@ -108,14 +107,11 @@ object ImageProvider {
|
|||||||
book: Book,
|
book: Book,
|
||||||
src: String,
|
src: String,
|
||||||
width: Int,
|
width: Int,
|
||||||
height: Int? = null,
|
height: Int? = null
|
||||||
bookSource: BookSource? = null
|
|
||||||
): Bitmap {
|
): Bitmap {
|
||||||
val cacheBitmap = bitmapLruCache.get(src)
|
val cacheBitmap = bitmapLruCache.get(src)
|
||||||
if (cacheBitmap != null) return cacheBitmap
|
if (cacheBitmap != null) return cacheBitmap
|
||||||
val vFile = runBlocking {
|
val vFile = BookHelp.getImage(book, src)
|
||||||
cacheImage(book, src, bookSource)
|
|
||||||
}
|
|
||||||
@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)
|
||||||
|
|||||||
Reference in New Issue
Block a user