|
|
|
@ -113,9 +113,6 @@ 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, |
|
|
|
@ -126,7 +123,6 @@ class ContentTextView(context: Context, attrs: AttributeSet?) : View(context, at |
|
|
|
|
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 { |
|
|
|
|
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,11 +160,10 @@ 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) |
|
|
|
@ -173,7 +172,6 @@ class ContentTextView(context: Context, attrs: AttributeSet?) : View(context, at |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* 滚动事件 |
|
|
|
|