|
|
|
@ -28,7 +28,7 @@ import io.legado.app.utils.toastOnUi |
|
|
|
|
import kotlin.math.min |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* 阅读内容界面 |
|
|
|
|
* 阅读内容视图 |
|
|
|
|
*/ |
|
|
|
|
class ContentTextView(context: Context, attrs: AttributeSet?) : View(context, attrs) { |
|
|
|
|
var selectAble = context.getPrefBoolean(PreferKey.textSelectAble, true) |
|
|
|
@ -65,12 +65,18 @@ class ContentTextView(context: Context, attrs: AttributeSet?) : View(context, at |
|
|
|
|
callBack = activity as CallBack |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* 设置内容 |
|
|
|
|
*/ |
|
|
|
|
fun setContent(textPage: TextPage) { |
|
|
|
|
this.textPage = textPage |
|
|
|
|
imagePaint.isAntiAlias = AppConfig.useAntiAlias |
|
|
|
|
invalidate() |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* 更新绘制区域 |
|
|
|
|
*/ |
|
|
|
|
fun upVisibleRect() { |
|
|
|
|
visibleRect.set( |
|
|
|
|
ChapterProvider.paddingLeft.toFloat(), |
|
|
|
@ -121,6 +127,9 @@ class ContentTextView(context: Context, attrs: AttributeSet?) : View(context, at |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* 绘制页面 |
|
|
|
|
*/ |
|
|
|
|
private fun draw( |
|
|
|
|
canvas: Canvas, |
|
|
|
|
textPage: TextPage, |
|
|
|
@ -259,6 +268,9 @@ class ContentTextView(context: Context, attrs: AttributeSet?) : View(context, at |
|
|
|
|
invalidate() |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* 重置滚动位置 |
|
|
|
|
*/ |
|
|
|
|
fun resetPageOffset() { |
|
|
|
|
pageOffset = 0 |
|
|
|
|
} |
|
|
|
@ -288,6 +300,9 @@ class ContentTextView(context: Context, attrs: AttributeSet?) : View(context, at |
|
|
|
|
* @return true:已处理, false:未处理 |
|
|
|
|
*/ |
|
|
|
|
fun click(x: Float, y: Float): Boolean { |
|
|
|
|
touch(x, y) { _, relativePos, textPage, lineIndex, textLine, charIndex, textChar -> |
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
return false |
|
|
|
|
} |
|
|
|
|
|
|
|
|
@ -342,6 +357,10 @@ class ContentTextView(context: Context, attrs: AttributeSet?) : View(context, at |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* 触碰位置信息 |
|
|
|
|
* @param touched 回调 |
|
|
|
|
*/ |
|
|
|
|
private fun touch( |
|
|
|
|
x: Float, |
|
|
|
|
y: Float, |
|
|
|
|