pull/34/head
kunfei 5 years ago
parent 025581bd87
commit 9a5679ea28
  1. 17
      app/src/main/java/io/legado/app/ui/widget/page/delegate/CoverPageDelegate.kt

@ -8,7 +8,6 @@ import io.legado.app.ui.widget.page.PageView
class CoverPageDelegate(pageView: PageView) : PageDelegate(pageView) { class CoverPageDelegate(pageView: PageView) : PageDelegate(pageView) {
private val shadowDrawableR: GradientDrawable private val shadowDrawableR: GradientDrawable
private val shadowDrawableL: GradientDrawable
private val bitmapMatrix = Matrix() private val bitmapMatrix = Matrix()
init { init {
@ -17,11 +16,6 @@ class CoverPageDelegate(pageView: PageView) : PageDelegate(pageView) {
GradientDrawable.Orientation.LEFT_RIGHT, shadowColors GradientDrawable.Orientation.LEFT_RIGHT, shadowColors
) )
shadowDrawableR.gradientType = GradientDrawable.LINEAR_GRADIENT shadowDrawableR.gradientType = GradientDrawable.LINEAR_GRADIENT
shadowDrawableL = GradientDrawable(
GradientDrawable.Orientation.RIGHT_LEFT, shadowColors
)
shadowDrawableL.gradientType = GradientDrawable.LINEAR_GRADIENT
} }
override fun onScrollStart() { override fun onScrollStart() {
@ -47,6 +41,8 @@ class CoverPageDelegate(pageView: PageView) : PageDelegate(pageView) {
} }
override fun onScrollStop() { override fun onScrollStop() {
curPage?.x = 0.toFloat()
if (!isCancel) { if (!isCancel) {
pageView.fillPage(direction) pageView.fillPage(direction)
} }
@ -61,9 +57,12 @@ class CoverPageDelegate(pageView: PageView) : PageDelegate(pageView) {
val distanceX = if (offsetX > 0) offsetX - viewWidth else offsetX + viewWidth val distanceX = if (offsetX > 0) offsetX - viewWidth else offsetX + viewWidth
bitmap?.let { bitmap?.let {
if (distanceX < 0) {
bitmapMatrix.setTranslate(distanceX, 0.toFloat()) bitmapMatrix.setTranslate(distanceX, 0.toFloat())
canvas.drawBitmap(it, bitmapMatrix, null) canvas.drawBitmap(it, bitmapMatrix, null)
} else {
curPage?.translationX = offsetX
}
addShadow(distanceX.toInt(), canvas) addShadow(distanceX.toInt(), canvas)
} }
} }
@ -73,8 +72,8 @@ class CoverPageDelegate(pageView: PageView) : PageDelegate(pageView) {
shadowDrawableR.setBounds(left + viewWidth, 0, left + viewWidth + 30, viewHeight) shadowDrawableR.setBounds(left + viewWidth, 0, left + viewWidth + 30, viewHeight)
shadowDrawableR.draw(canvas) shadowDrawableR.draw(canvas)
} else { } else {
shadowDrawableL.setBounds(left - 30, 0, left, viewHeight) shadowDrawableR.setBounds(left, 0, left + 30, viewHeight)
shadowDrawableL.draw(canvas) shadowDrawableR.draw(canvas)
} }
} }
} }

Loading…
Cancel
Save