pull/1705/head
kunfei 3 years ago
parent bf40ba3546
commit 01d1669d0f
  1. 22
      app/src/main/java/io/legado/app/constant/PageAnim.kt
  2. 3
      app/src/main/java/io/legado/app/data/entities/Book.kt
  3. 5
      app/src/main/java/io/legado/app/help/config/ReadBookConfig.kt
  4. 11
      app/src/main/java/io/legado/app/ui/book/read/page/ReadView.kt

@ -0,0 +1,22 @@
package io.legado.app.constant
import androidx.annotation.IntDef
object PageAnim {
const val coverPageAnim = 0
const val slidePageAnim = 1
const val simulationPageAnim = 2
const val scrollPageAnim = 3
const val noAnim = 4
@Target(AnnotationTarget.VALUE_PARAMETER)
@Retention(AnnotationRetention.SOURCE)
@IntDef(coverPageAnim, slidePageAnim, simulationPageAnim, scrollPageAnim, noAnim)
annotation class Anim
}

@ -4,6 +4,7 @@ import android.os.Parcelable
import androidx.room.*
import io.legado.app.constant.AppPattern
import io.legado.app.constant.BookType
import io.legado.app.constant.PageAnim
import io.legado.app.data.appDb
import io.legado.app.help.config.AppConfig
import io.legado.app.help.config.ReadBookConfig
@ -207,7 +208,7 @@ data class Book(
fun getPageAnim(): Int {
var pageAnim = config.pageAnim
?: if (type == BookType.image) 3 else ReadBookConfig.pageAnim
?: if (type == BookType.image) PageAnim.scrollPageAnim else ReadBookConfig.pageAnim
if (pageAnim < 0) {
pageAnim = ReadBookConfig.pageAnim
}

@ -7,6 +7,7 @@ import android.graphics.drawable.Drawable
import androidx.annotation.Keep
import io.legado.app.R
import io.legado.app.constant.AppLog
import io.legado.app.constant.PageAnim
import io.legado.app.constant.PreferKey
import io.legado.app.help.DefaultData
import io.legado.app.help.coroutine.Coroutine
@ -173,7 +174,7 @@ object ReadBookConfig {
var pageAnim: Int
get() = config.curPageAnim()
set(value) {
set(@PageAnim.Anim value) {
config.setCurPageAnim(value)
}
@ -515,7 +516,7 @@ object ReadBookConfig {
}
}
fun setCurPageAnim(anim: Int) {
fun setCurPageAnim(@PageAnim.Anim anim: Int) {
when {
AppConfig.isEInkMode -> pageAnimEInk = anim
else -> pageAnim = anim

@ -12,6 +12,7 @@ import android.view.MotionEvent
import android.view.ViewConfiguration
import android.view.WindowInsets
import android.widget.FrameLayout
import io.legado.app.constant.PageAnim
import io.legado.app.help.config.AppConfig
import io.legado.app.help.config.ReadBookConfig
import io.legado.app.lib.theme.accentColor
@ -127,7 +128,7 @@ class ReadView(context: Context, attrs: AttributeSet) :
super.dispatchDraw(canvas)
pageDelegate?.onDraw(canvas)
if (!isInEditMode && callBack.isAutoPage && !isScroll) {
// TODO 自动翻页
// 自动翻页
nextPage.screenshot()?.let {
val bottom = callBack.autoPageProgress
autoPageRect.set(0, 0, width, bottom)
@ -481,16 +482,16 @@ class ReadView(context: Context, attrs: AttributeSet) :
isScroll = ReadBook.pageAnim() == 3
ChapterProvider.upLayout()
when (ReadBook.pageAnim()) {
0 -> if (pageDelegate !is CoverPageDelegate) {
PageAnim.coverPageAnim -> if (pageDelegate !is CoverPageDelegate) {
pageDelegate = CoverPageDelegate(this)
}
1 -> if (pageDelegate !is SlidePageDelegate) {
PageAnim.slidePageAnim -> if (pageDelegate !is SlidePageDelegate) {
pageDelegate = SlidePageDelegate(this)
}
2 -> if (pageDelegate !is SimulationPageDelegate) {
PageAnim.simulationPageAnim -> if (pageDelegate !is SimulationPageDelegate) {
pageDelegate = SimulationPageDelegate(this)
}
3 -> if (pageDelegate !is ScrollPageDelegate) {
PageAnim.scrollPageAnim -> if (pageDelegate !is ScrollPageDelegate) {
pageDelegate = ScrollPageDelegate(this)
}
else -> if (pageDelegate !is NoAnimPageDelegate) {

Loading…
Cancel
Save