diff --git a/app/src/main/java/io/legado/app/ui/book/read/page/ContentTextView.kt b/app/src/main/java/io/legado/app/ui/book/read/page/ContentTextView.kt index 10a454109..3fba231a4 100644 --- a/app/src/main/java/io/legado/app/ui/book/read/page/ContentTextView.kt +++ b/app/src/main/java/io/legado/app/ui/book/read/page/ContentTextView.kt @@ -113,19 +113,15 @@ class ContentTextView(context: Context, attrs: AttributeSet?) : View(context, at val lineTop = textLine.lineTop + relativeOffset val lineBase = textLine.lineBase + relativeOffset val lineBottom = textLine.lineBottom + relativeOffset - if (textLine.isImage) { - drawImage(canvas, textLine, lineTop, lineBottom) - } else { - drawChars( - canvas, - textLine.textChars, - lineTop, - lineBase, - lineBottom, - isTitle = textLine.isTitle, - isReadAloud = textLine.isReadAloud - ) - } + drawChars( + canvas, + textLine.textChars, + lineTop, + lineBase, + lineBottom, + isTitle = textLine.isTitle, + isReadAloud = textLine.isReadAloud + ) } /** @@ -148,7 +144,11 @@ class ContentTextView(context: Context, attrs: AttributeSet?) : View(context, at textPaint.color = if (isReadAloud) context.accentColor else ReadBookConfig.textColor textChars.forEach { - canvas.drawText(it.charData, it.start, lineBase, textPaint) + if (it.isImage) { + drawImage(canvas, it, lineTop, lineBottom) + } else { + canvas.drawText(it.charData, it.start, lineBase, textPaint) + } if (it.selected) { canvas.drawRect(it.start, lineTop, it.end, lineBottom, selectedPaint) } @@ -160,18 +160,16 @@ class ContentTextView(context: Context, attrs: AttributeSet?) : View(context, at */ private fun drawImage( canvas: Canvas, - textLine: TextLine, + textChar: TextChar, lineTop: Float, lineBottom: Float, ) { - textLine.textChars.forEach { textChar -> - ReadBook.book?.let { book -> - val rectF = RectF(textChar.start, lineTop, textChar.end, lineBottom) - ImageProvider.getImage(book, textPage.chapterIndex, textChar.charData, true) - ?.let { - canvas.drawBitmap(it, null, rectF, null) - } - } + ReadBook.book?.let { book -> + val rectF = RectF(textChar.start, lineTop, textChar.end, lineBottom) + ImageProvider.getImage(book, textPage.chapterIndex, textChar.charData, true) + ?.let { + canvas.drawBitmap(it, null, rectF, null) + } } } diff --git a/app/src/main/java/io/legado/app/ui/book/read/page/entities/TextLine.kt b/app/src/main/java/io/legado/app/ui/book/read/page/entities/TextLine.kt index 9d73757bb..fe02e4f48 100644 --- a/app/src/main/java/io/legado/app/ui/book/read/page/entities/TextLine.kt +++ b/app/src/main/java/io/legado/app/ui/book/read/page/entities/TextLine.kt @@ -12,7 +12,6 @@ data class TextLine( var lineBase: Float = 0f, var lineBottom: Float = 0f, val isTitle: Boolean = false, - val isImage: Boolean = false, var isReadAloud: Boolean = false ) { diff --git a/app/src/main/java/io/legado/app/ui/book/read/page/provider/ChapterProvider.kt b/app/src/main/java/io/legado/app/ui/book/read/page/provider/ChapterProvider.kt index 4f8ccbe21..e2e963431 100644 --- a/app/src/main/java/io/legado/app/ui/book/read/page/provider/ChapterProvider.kt +++ b/app/src/main/java/io/legado/app/ui/book/read/page/provider/ChapterProvider.kt @@ -164,7 +164,7 @@ object ChapterProvider { } } } - val textLine = TextLine(isImage = true) + val textLine = TextLine() textLine.lineTop = durY durY += height textLine.lineBottom = durY