feat: 优化代码

pull/121/head
kunfei 5 years ago
parent 51c0ac8f1b
commit a17cd1fb7b
  1. 2
      app/src/main/java/io/legado/app/ui/book/read/ReadBookActivity.kt
  2. 1
      app/src/main/java/io/legado/app/ui/book/read/page/ContentTextView.kt
  3. 5
      app/src/main/java/io/legado/app/ui/book/read/page/PageView.kt
  4. 4
      app/src/main/java/io/legado/app/ui/book/read/page/delegate/PageDelegate.kt

@ -691,7 +691,7 @@ class ReadBookActivity : VMBaseActivity<ReadBookViewModel>(R.layout.activity_boo
upScreenTimeOut() upScreenTimeOut()
} }
observeEvent<Boolean>(PreferKey.textSelectAble) { observeEvent<Boolean>(PreferKey.textSelectAble) {
page_view.upSelectAble(it) page_view.curPage.upSelectAble(it)
} }
} }

@ -197,6 +197,7 @@ class ContentTextView(context: Context, attrs: AttributeSet?) : View(context, at
y: Float, y: Float,
select: (relativePage: Int, lineIndex: Int, charIndex: Int) -> Unit select: (relativePage: Int, lineIndex: Int, charIndex: Int) -> Unit
) { ) {
if (!selectAble) return
if (!visibleRect.contains(x, y)) return if (!visibleRect.contains(x, y)) return
var relativeOffset = relativeOffset(0) var relativeOffset = relativeOffset(0)
for ((lineIndex, textLine) in textPage.textLines.withIndex()) { for ((lineIndex, textLine) in textPage.textLines.withIndex()) {

@ -132,11 +132,6 @@ class PageView(context: Context, attrs: AttributeSet) :
} }
} }
fun upSelectAble(selectAble: Boolean) {
pageDelegate?.upSelectAble(selectAble)
curPage.upSelectAble(selectAble)
}
fun upStyle() { fun upStyle() {
ChapterProvider.upStyle() ChapterProvider.upStyle()
curPage.upStyle() curPage.upStyle()

@ -101,10 +101,6 @@ abstract class PageDelegate(protected val pageView: PageView) :
onScroll() onScroll()
} }
fun upSelectAble(selectAble: Boolean) {
detector.setIsLongpressEnabled(selectAble)
}
open fun fling( open fun fling(
startX: Int, startY: Int, velocityX: Int, velocityY: Int, startX: Int, startY: Int, velocityX: Int, velocityY: Int,
minX: Int, maxX: Int, minY: Int, maxY: Int minX: Int, maxX: Int, minY: Int, maxY: Int

Loading…
Cancel
Save