pull/2091/head
821938089 2 years ago
parent a644951a08
commit 7b02f722a3
  1. 1
      app/src/main/java/io/legado/app/ui/book/read/ReadBookActivity.kt
  2. 8
      app/src/main/java/io/legado/app/ui/book/read/page/PageView.kt
  3. 3
      app/src/main/java/io/legado/app/ui/book/read/page/ReadView.kt
  4. 39
      app/src/main/java/io/legado/app/ui/book/read/page/delegate/CoverPageDelegate.kt
  5. 2
      app/src/main/java/io/legado/app/ui/book/read/page/delegate/HorizontalPageDelegate.kt
  6. 5
      app/src/main/java/io/legado/app/ui/book/read/page/delegate/NoAnimPageDelegate.kt

@ -164,6 +164,7 @@ class ReadBookActivity : BaseReadBookActivity(),
binding.cursorRight.setColorFilter(accentColor)
binding.cursorLeft.setOnTouchListener(this)
binding.cursorRight.setOnTouchListener(this)
window.setBackgroundDrawable(null)
upScreenTimeOut()
ReadBook.callBack = this
}

@ -49,8 +49,6 @@ class PageView(context: Context) : FrameLayout(context) {
init {
if (!isInEditMode) {
//设置背景防止切换背景时文字重叠
setBackgroundColor(context.getCompatColor(R.color.background))
upStyle()
}
binding.contentTextView.upView = {
@ -202,7 +200,11 @@ class PageView(context: Context) : FrameLayout(context) {
}
fun upBg() {
binding.vwRoot.backgroundColor = ReadBookConfig.bgMeanColor
if (ReadBookConfig.bgAlpha < 100) {
binding.vwRoot.backgroundColor = ReadBookConfig.bgMeanColor
} else {
binding.vwRoot.background = null
}
binding.vwBg.background = ReadBookConfig.bg
upBgAlpha()
}

@ -26,6 +26,7 @@ import io.legado.app.ui.book.read.page.entities.TextPos
import io.legado.app.ui.book.read.page.provider.ChapterProvider
import io.legado.app.ui.book.read.page.provider.TextPageFactory
import io.legado.app.utils.activity
import io.legado.app.utils.invisible
import io.legado.app.utils.screenshot
import java.text.BreakIterator
import java.util.*
@ -97,6 +98,8 @@ class ReadView(context: Context, attrs: AttributeSet) :
addView(nextPage)
addView(curPage)
addView(prevPage)
nextPage.invisible()
prevPage.invisible()
if (!isInEditMode) {
upBg()
setWillNotDraw(false)

@ -5,6 +5,7 @@ import android.graphics.Matrix
import android.graphics.drawable.GradientDrawable
import io.legado.app.ui.book.read.page.ReadView
import io.legado.app.ui.book.read.page.entities.PageDirection
import io.legado.app.utils.screenshot
class CoverPageDelegate(readView: ReadView) : HorizontalPageDelegate(readView) {
private val bitmapMatrix = Matrix()
@ -30,18 +31,46 @@ class CoverPageDelegate(readView: ReadView) : HorizontalPageDelegate(readView) {
val distanceX = if (offsetX > 0) offsetX - viewWidth else offsetX + viewWidth
if (mDirection == PageDirection.PREV) {
bitmapMatrix.setTranslate(distanceX, 0.toFloat())
curBitmap?.let { canvas.drawBitmap(it, 0f, 0f, null) }
prevBitmap?.let { canvas.drawBitmap(it, bitmapMatrix, null) }
addShadow(distanceX.toInt(), canvas)
if (offsetX <= viewWidth) {
bitmapMatrix.setTranslate(distanceX, 0.toFloat())
prevBitmap?.let { canvas.drawBitmap(it, bitmapMatrix, null) }
addShadow(distanceX.toInt(), canvas)
} else {
prevBitmap?.let { canvas.drawBitmap(it, 0f, 0f, null) }
}
} else if (mDirection == PageDirection.NEXT) {
bitmapMatrix.setTranslate(distanceX - viewWidth, 0.toFloat())
nextBitmap?.let { canvas.drawBitmap(it, 0f, 0f, null) }
nextBitmap?.let {
canvas.apply {
save()
val width = it.width.toFloat()
val height = it.height.toFloat()
clipRect(width + offsetX, 0f, width, height)
drawBitmap(it, 0f, 0f, null)
restore()
}
}
curBitmap?.let { canvas.drawBitmap(it, bitmapMatrix, null) }
addShadow(distanceX.toInt(), canvas)
}
}
override fun setBitmap() {
when (mDirection) {
PageDirection.PREV -> {
prevBitmap?.recycle()
prevBitmap = prevPage.screenshot()
}
PageDirection.NEXT -> {
nextBitmap?.recycle()
nextBitmap = nextPage.screenshot()
curBitmap?.recycle()
curBitmap = curPage.screenshot()
}
else -> Unit
}
}
private fun addShadow(left: Int, canvas: Canvas) {
if (left < 0) {
shadowDrawableR.setBounds(left + viewWidth, 0, left + viewWidth + 30, viewHeight)

@ -17,7 +17,7 @@ abstract class HorizontalPageDelegate(readView: ReadView) : PageDelegate(readVie
setBitmap()
}
private fun setBitmap() {
open fun setBitmap() {
when (mDirection) {
PageDirection.PREV -> {
prevBitmap?.recycle()

@ -2,9 +2,14 @@ package io.legado.app.ui.book.read.page.delegate
import android.graphics.Canvas
import io.legado.app.ui.book.read.page.ReadView
import io.legado.app.ui.book.read.page.entities.PageDirection
class NoAnimPageDelegate(readView: ReadView) : HorizontalPageDelegate(readView) {
override fun setDirection(direction: PageDirection) {
mDirection = direction
}
override fun onAnimStart(animationSpeed: Int) {
if (!isCancel) {
readView.fillPage(mDirection)

Loading…
Cancel
Save