feat: 优化代码

pull/115/head
kunfei 5 years ago
parent 41ea3a7eb4
commit 3aa9b034d5
  1. 6
      app/src/main/java/io/legado/app/ui/book/read/page/ContentTextView.kt
  2. 3
      app/src/main/java/io/legado/app/ui/book/read/page/ContentView.kt
  3. 2
      app/src/main/java/io/legado/app/ui/book/read/page/delegate/PageDelegate.kt

@ -4,7 +4,6 @@ import android.content.Context
import android.graphics.Canvas import android.graphics.Canvas
import android.graphics.Paint import android.graphics.Paint
import android.util.AttributeSet import android.util.AttributeSet
import android.util.Log
import android.view.View import android.view.View
import io.legado.app.R import io.legado.app.R
import io.legado.app.constant.PreferKey import io.legado.app.constant.PreferKey
@ -159,14 +158,13 @@ class ContentTextView(context: Context, attrs: AttributeSet?) : View(context, at
if (pageOffset > 0) { if (pageOffset > 0) {
pageFactory.moveToPrev() pageFactory.moveToPrev()
textPage = pageFactory.currentPage ?: TextPage().format() textPage = pageFactory.currentPage ?: TextPage().format()
Log.e("pageOffSet", pageOffset.toString() + " " + textPage.height)
pageOffset -= textPage.height pageOffset -= textPage.height
callBack.upContent(0, false) // callBack.upContent(0, false)
} else if (pageOffset < -textPage.height) { } else if (pageOffset < -textPage.height) {
pageOffset += textPage.height pageOffset += textPage.height
pageFactory.moveToNext() pageFactory.moveToNext()
textPage = pageFactory.currentPage ?: TextPage().format() textPage = pageFactory.currentPage ?: TextPage().format()
callBack.upContent(0, false) // callBack.upContent(0, false)
} }
invalidate() invalidate()
} }

@ -99,10 +99,11 @@ class ContentView(context: Context) : FrameLayout(context) {
if (resetScrollOffset) { if (resetScrollOffset) {
content_text_view.resetPageOffset() content_text_view.resetPageOffset()
content_text_view.setContent(textPage) content_text_view.setContent(textPage)
} } else {
content_text_view.invalidate() content_text_view.invalidate()
} }
} }
}
@SuppressLint("SetTextI18n") @SuppressLint("SetTextI18n")
fun setPageIndex(pageIndex: Int?) { fun setPageIndex(pageIndex: Int?) {

@ -140,7 +140,7 @@ abstract class PageDelegate(protected val pageView: PageView) :
if (scroller.computeScrollOffset()) { if (scroller.computeScrollOffset()) {
setTouchPoint(scroller.currX.toFloat(), scroller.currY.toFloat()) setTouchPoint(scroller.currX.toFloat(), scroller.currY.toFloat())
} else if (isStarted) { } else if (isStarted) {
setTouchPoint(scroller.finalX.toFloat(), scroller.finalY.toFloat(), false) setTouchPoint(scroller.currY.toFloat(), scroller.finalY.toFloat(), false)
onAnimStop() onAnimStop()
stopScroll() stopScroll()
} }

Loading…
Cancel
Save