优化
This commit is contained in:
@@ -101,7 +101,7 @@ object ChapterProvider {
|
|||||||
/**
|
/**
|
||||||
* 获取拆分完的章节数据
|
* 获取拆分完的章节数据
|
||||||
*/
|
*/
|
||||||
fun getTextChapter(
|
suspend fun getTextChapter(
|
||||||
book: Book,
|
book: Book,
|
||||||
bookChapter: BookChapter,
|
bookChapter: BookChapter,
|
||||||
displayTitle: String,
|
displayTitle: String,
|
||||||
@@ -136,7 +136,6 @@ object ChapterProvider {
|
|||||||
while (matcher.find()) {
|
while (matcher.find()) {
|
||||||
matcher.group(1)?.let { src ->
|
matcher.group(1)?.let { src ->
|
||||||
srcList.add(src)
|
srcList.add(src)
|
||||||
ImageProvider.getImage(book, src, ReadBook.bookSource)
|
|
||||||
matcher.appendReplacement(sb, srcReplaceChar)
|
matcher.appendReplacement(sb, srcReplaceChar)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -200,7 +199,7 @@ object ChapterProvider {
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun setTypeImage(
|
private suspend fun setTypeImage(
|
||||||
book: Book,
|
book: Book,
|
||||||
src: String,
|
src: String,
|
||||||
x: Int,
|
x: Int,
|
||||||
@@ -209,7 +208,7 @@ object ChapterProvider {
|
|||||||
imageStyle: String?,
|
imageStyle: String?,
|
||||||
): Float {
|
): Float {
|
||||||
var durY = y
|
var durY = y
|
||||||
ImageProvider.getImage(book, src, ReadBook.bookSource)?.let {
|
ImageProvider.getImageSize(book, src, ReadBook.bookSource).let {
|
||||||
if (durY > visibleHeight) {
|
if (durY > visibleHeight) {
|
||||||
textPages.last().height = durY
|
textPages.last().height = durY
|
||||||
textPages.add(TextPage())
|
textPages.add(TextPage())
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
package io.legado.app.ui.book.read.page.provider
|
package io.legado.app.ui.book.read.page.provider
|
||||||
|
|
||||||
import android.graphics.Bitmap
|
import android.graphics.Bitmap
|
||||||
|
import android.graphics.BitmapFactory
|
||||||
import android.util.Size
|
import android.util.Size
|
||||||
import io.legado.app.R
|
import io.legado.app.R
|
||||||
import io.legado.app.constant.AppLog.putDebug
|
import io.legado.app.constant.AppLog.putDebug
|
||||||
@@ -10,7 +11,6 @@ import io.legado.app.help.BookHelp
|
|||||||
import io.legado.app.help.coroutine.Coroutine
|
import io.legado.app.help.coroutine.Coroutine
|
||||||
import io.legado.app.help.glide.ImageLoader
|
import io.legado.app.help.glide.ImageLoader
|
||||||
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.FileUtils
|
import io.legado.app.utils.FileUtils
|
||||||
import io.legado.app.utils.isXml
|
import io.legado.app.utils.isXml
|
||||||
import kotlinx.coroutines.runBlocking
|
import kotlinx.coroutines.runBlocking
|
||||||
@@ -22,13 +22,8 @@ import kotlin.coroutines.resume
|
|||||||
|
|
||||||
object ImageProvider {
|
object ImageProvider {
|
||||||
|
|
||||||
private val errorBitmap: Bitmap? by lazy {
|
private val errorBitmap: Bitmap by lazy {
|
||||||
BitmapUtils.decodeBitmap(
|
BitmapFactory.decodeResource(appCtx.resources, R.drawable.image_loading_error)
|
||||||
appCtx,
|
|
||||||
R.drawable.image_loading_error,
|
|
||||||
ChapterProvider.visibleWidth,
|
|
||||||
ChapterProvider.visibleHeight
|
|
||||||
)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private suspend fun cacheImage(
|
private suspend fun cacheImage(
|
||||||
@@ -66,12 +61,12 @@ object ImageProvider {
|
|||||||
block.resume(Size(width, height))
|
block.resume(Size(width, height))
|
||||||
}
|
}
|
||||||
}.onFailure {
|
}.onFailure {
|
||||||
block.cancel(it)
|
block.resume(Size(errorBitmap.width, errorBitmap.height))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fun getImage(
|
suspend fun getImage(
|
||||||
book: Book,
|
book: Book,
|
||||||
src: String,
|
src: String,
|
||||||
bookSource: BookSource?,
|
bookSource: BookSource?,
|
||||||
|
|||||||
Reference in New Issue
Block a user