pull/34/head
kunfei 5 years ago
parent 8a653f17ac
commit ff717c16d2
  1. 64
      app/src/main/java/io/legado/app/ui/widget/page/delegate/PageDelegate.kt

@ -274,7 +274,9 @@ abstract class PageDelegate(protected val pageView: PageView) {
if (!isMoved && abs(distanceX) < abs(distanceY)) { if (!isMoved && abs(distanceX) < abs(distanceY)) {
if (distanceY < 0) { if (distanceY < 0) {
if (atTop) { if (atTop) {
curPage?.dispatchTouchEvent(e1.toAction(MotionEvent.ACTION_UP)) val event = e1.toAction(MotionEvent.ACTION_UP)
curPage?.dispatchTouchEvent(event)
event.recycle()
//上一页的参数配置 //上一页的参数配置
direction = Direction.PREV direction = Direction.PREV
//判断是否上一页存在 //判断是否上一页存在
@ -289,7 +291,9 @@ abstract class PageDelegate(protected val pageView: PageView) {
} }
} else { } else {
if (atBottom) { if (atBottom) {
curPage?.dispatchTouchEvent(e1.toAction(MotionEvent.ACTION_UP)) val event = e1.toAction(MotionEvent.ACTION_UP)
curPage?.dispatchTouchEvent(event)
event.recycle()
//进行下一页的配置 //进行下一页的配置
direction = Direction.NEXT direction = Direction.NEXT
//判断是否下一页存在 //判断是否下一页存在
@ -309,34 +313,38 @@ abstract class PageDelegate(protected val pageView: PageView) {
//传递触摸事件到textView //传递触摸事件到textView
curPage?.dispatchTouchEvent(e2) curPage?.dispatchTouchEvent(e2)
} }
} else if (!isMoved && abs(distanceX) > abs(distanceY)) { } else if (!isMoved) {
curPage?.dispatchTouchEvent(e1.toAction(MotionEvent.ACTION_UP)) val event = e1.toAction(MotionEvent.ACTION_UP)
if (distanceX < 0) { curPage?.dispatchTouchEvent(event)
//上一页的参数配置 event.recycle()
direction = Direction.PREV if (abs(distanceX) > abs(distanceY)) {
//判断是否上一页存在 if (distanceX < 0) {
val hasPrev = pageView.hasPrev() //上一页的参数配置
//如果上一页不存在 direction = Direction.PREV
if (!hasPrev) { //判断是否上一页存在
noNext = true val hasPrev = pageView.hasPrev()
return true //如果上一页不存在
} if (!hasPrev) {
//上一页截图 noNext = true
bitmap = prevPage?.screenshot() return true
} else { }
//进行下一页的配置 //上一页截图
direction = Direction.NEXT bitmap = prevPage?.screenshot()
//判断是否下一页存在 } else {
val hasNext = pageView.hasNext() //进行下一页的配置
//如果不存在表示没有下一页了 direction = Direction.NEXT
if (!hasNext) { //判断是否下一页存在
noNext = true val hasNext = pageView.hasNext()
return true //如果不存在表示没有下一页了
if (!hasNext) {
noNext = true
return true
}
//下一页截图
bitmap = nextPage?.screenshot()
} }
//下一页截图 isMoved = true
bitmap = nextPage?.screenshot()
} }
isMoved = true
} }
if (isMoved) { if (isMoved) {
isCancel = if (pageView.isScrollDelegate) { isCancel = if (pageView.isScrollDelegate) {

Loading…
Cancel
Save