优化
This commit is contained in:
@@ -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,
|
||||||
|
|||||||
@@ -24,7 +24,7 @@ import splitties.views.backgroundColor
|
|||||||
import java.util.*
|
import java.util.*
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 阅读界面
|
* 页面视图
|
||||||
*/
|
*/
|
||||||
class PageView(context: Context) : FrameLayout(context) {
|
class PageView(context: Context) : FrameLayout(context) {
|
||||||
|
|
||||||
|
|||||||
@@ -32,7 +32,9 @@ import java.text.BreakIterator
|
|||||||
import java.util.*
|
import java.util.*
|
||||||
import kotlin.math.abs
|
import kotlin.math.abs
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 阅读视图
|
||||||
|
*/
|
||||||
class ReadView(context: Context, attrs: AttributeSet) :
|
class ReadView(context: Context, attrs: AttributeSet) :
|
||||||
FrameLayout(context, attrs),
|
FrameLayout(context, attrs),
|
||||||
DataSource {
|
DataSource {
|
||||||
|
|||||||
Reference in New Issue
Block a user