| 
						
						
							
								
							
						
						
					 | 
					 | 
					@ -3,7 +3,9 @@ package io.legado.app.ui.book.read.page.delegate | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					import android.graphics.* | 
					 | 
					 | 
					 | 
					import android.graphics.* | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					import android.graphics.drawable.GradientDrawable | 
					 | 
					 | 
					 | 
					import android.graphics.drawable.GradientDrawable | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					import android.os.Build | 
					 | 
					 | 
					 | 
					import android.os.Build | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					import android.view.MotionEvent | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					import io.legado.app.ui.book.read.page.PageView | 
					 | 
					 | 
					 | 
					import io.legado.app.ui.book.read.page.PageView | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					import io.legado.app.utils.screenshot | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					import kotlin.math.* | 
					 | 
					 | 
					 | 
					import kotlin.math.* | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					
 | 
					 | 
					 | 
					 | 
					
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					@Suppress("DEPRECATION") | 
					 | 
					 | 
					 | 
					@Suppress("DEPRECATION") | 
				
			
			
		
	
	
		
		
			
				
					| 
						
							
								
							
						
						
							
								
							
						
						
					 | 
					 | 
					@ -74,6 +76,9 @@ class SimulationPageDelegate(pageView: PageView) : HorizontalPageDelegate(pageVi | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					        ) | 
					 | 
					 | 
					 | 
					        ) | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					        cm.set(array) | 
					 | 
					 | 
					 | 
					        cm.set(array) | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					        mColorMatrixFilter = ColorMatrixColorFilter(cm) | 
					 | 
					 | 
					 | 
					        mColorMatrixFilter = ColorMatrixColorFilter(cm) | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					        touchX = 0.01f //不让x,y为0,否则在点计算时会有问题 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					        touchY = 0.01f | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					    } | 
					 | 
					 | 
					 | 
					    } | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					
 | 
					 | 
					 | 
					 | 
					
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					    override fun setStartPoint(x: Float, y: Float, invalidate: Boolean) { | 
					 | 
					 | 
					 | 
					    override fun setStartPoint(x: Float, y: Float, invalidate: Boolean) { | 
				
			
			
		
	
	
		
		
			
				
					| 
						
							
								
							
						
						
							
								
							
						
						
					 | 
					 | 
					@ -100,6 +105,48 @@ class SimulationPageDelegate(pageView: PageView) : HorizontalPageDelegate(pageVi | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					        } | 
					 | 
					 | 
					 | 
					        } | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					    } | 
					 | 
					 | 
					 | 
					    } | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					
 | 
					 | 
					 | 
					 | 
					
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					    override fun onScroll( | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					        e1: MotionEvent, | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					        e2: MotionEvent, | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					        distanceX: Float, | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					        distanceY: Float | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					    ): Boolean { | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					        if (!isMoved) { | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					            val event = e1.toAction(MotionEvent.ACTION_UP) | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					            curPage.dispatchTouchEvent(event) | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					            event.recycle() | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					            if (abs(distanceX) > abs(distanceY)) { | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					                if (distanceX < 0) { | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					                    //如果上一页不存在 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					                    if (!hasPrev()) { | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					                        noNext = true | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					                        return true | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					                    } | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					                    //上一页截图 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					                    prevBitmap = prevPage.screenshot() | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					                    curBitmap = curPage.screenshot() | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					                } else { | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					                    //如果不存在表示没有下一页了 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					                    if (!hasNext()) { | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					                        noNext = true | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					                        return true | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					                    } | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					                    //下一页截图 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					                    nextBitmap = nextPage.screenshot() | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					                    curBitmap = curPage.screenshot() | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					                } | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					                isMoved = true | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					            } | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					        } | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					        if (isMoved) { | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					            isCancel = if (direction == Direction.NEXT) distanceX < 0 else distanceX > 0 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					            isRunning = true | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					            //设置触摸点 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					            setTouchPoint(e2.x, e2.y) | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					        } | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					        return isMoved | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					    } | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					    override fun onScrollStart() { | 
					 | 
					 | 
					 | 
					    override fun onScrollStart() { | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					        val distanceX: Float | 
					 | 
					 | 
					 | 
					        val distanceX: Float | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					        when (direction) { | 
					 | 
					 | 
					 | 
					        when (direction) { | 
				
			
			
		
	
	
		
		
			
				
					| 
						
							
								
							
						
						
							
								
							
						
						
					 | 
					 | 
					@ -132,20 +179,18 @@ class SimulationPageDelegate(pageView: PageView) : HorizontalPageDelegate(pageVi | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					    } | 
					 | 
					 | 
					 | 
					    } | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					
 | 
					 | 
					 | 
					 | 
					
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					    override fun onDraw(canvas: Canvas) { | 
					 | 
					 | 
					 | 
					    override fun onDraw(canvas: Canvas) { | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					        bitmap?.let { | 
					 | 
					 | 
					 | 
					        if (direction === Direction.NEXT) { | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					            if (direction === Direction.NEXT) { | 
					 | 
					 | 
					 | 
					            calcPoints() | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					                calcPoints() | 
					 | 
					 | 
					 | 
					            drawCurrentPageArea(canvas, curBitmap, mPath0) | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					                drawCurrentPageArea(canvas, curBitmap, mPath0) //绘制翻页时的正面页 | 
					 | 
					 | 
					 | 
					            drawNextPageAreaAndShadow(canvas, nextBitmap) | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					                drawNextPageAreaAndShadow(canvas, nextBitmap) | 
					 | 
					 | 
					 | 
					            drawCurrentPageShadow(canvas) | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					                drawCurrentPageShadow(canvas) | 
					 | 
					 | 
					 | 
					            drawCurrentBackArea(canvas, curBitmap) | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					                drawCurrentBackArea(canvas, curBitmap) | 
					 | 
					 | 
					 | 
					        } else { | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					            } else { | 
					 | 
					 | 
					 | 
					            calcPoints() | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					                calcPoints() | 
					 | 
					 | 
					 | 
					            drawCurrentPageArea(canvas, prevBitmap, mPath0) | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					                drawCurrentPageArea(canvas, prevBitmap, mPath0) | 
					 | 
					 | 
					 | 
					            drawNextPageAreaAndShadow(canvas, curBitmap) | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					                drawNextPageAreaAndShadow(canvas, curBitmap) | 
					 | 
					 | 
					 | 
					            drawCurrentPageShadow(canvas) | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					                drawCurrentPageShadow(canvas) | 
					 | 
					 | 
					 | 
					            drawCurrentBackArea(canvas, prevBitmap) | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					                drawCurrentBackArea(canvas, prevBitmap) | 
					 | 
					 | 
					 | 
					 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					            } | 
					 | 
					 | 
					 | 
					 | 
				
			
			
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					        } | 
					 | 
					 | 
					 | 
					        } | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					    } | 
					 | 
					 | 
					 | 
					    } | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					
 | 
					 | 
					 | 
					 | 
					
 | 
				
			
			
		
	
	
		
		
			
				
					| 
						
							
								
							
						
						
							
								
							
						
						
					 | 
					 | 
					@ -404,6 +449,7 @@ class SimulationPageDelegate(pageView: PageView) : HorizontalPageDelegate(pageVi | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					        canvas.restore() | 
					 | 
					 | 
					 | 
					        canvas.restore() | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					    } | 
					 | 
					 | 
					 | 
					    } | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					
 | 
					 | 
					 | 
					 | 
					
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					    //绘制翻页时的正面页 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					    private fun drawCurrentPageArea( | 
					 | 
					 | 
					 | 
					    private fun drawCurrentPageArea( | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					        canvas: Canvas, | 
					 | 
					 | 
					 | 
					        canvas: Canvas, | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					        bitmap: Bitmap?, | 
					 | 
					 | 
					 | 
					        bitmap: Bitmap?, | 
				
			
			
		
	
	
		
		
			
				
					| 
						
							
								
							
						
						
						
					 | 
					 | 
					
  |