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