pull/32/head
kunfei 5 years ago
parent aa261f298d
commit 12504cd194
  1. 6
      app/src/main/java/io/legado/app/ui/readbook/config/ReadStyleDialog.kt
  2. 11
      app/src/main/java/io/legado/app/ui/widget/page/PageView.kt
  3. 9
      app/src/main/java/io/legado/app/ui/widget/page/delegate/PageDelegate.kt

@ -15,9 +15,11 @@ import io.legado.app.help.ReadBookConfig
import io.legado.app.lib.theme.accentColor
import io.legado.app.lib.theme.primaryColor
import io.legado.app.ui.readbook.Help
import io.legado.app.ui.readbook.ReadBookActivity
import io.legado.app.utils.getPrefInt
import io.legado.app.utils.postEvent
import io.legado.app.utils.putPrefInt
import kotlinx.android.synthetic.main.activity_read_book.*
import kotlinx.android.synthetic.main.dialog_read_book_style.*
import org.jetbrains.anko.sdk27.listeners.onCheckedChange
import org.jetbrains.anko.sdk27.listeners.onClick
@ -70,6 +72,10 @@ class ReadStyleDialog : DialogFragment() {
for (i in 0 until rg_page_anim.childCount) {
if (checkedId == rg_page_anim[i].id) {
requireContext().putPrefInt("pageAnim", i)
val activity = activity
if (activity is ReadBookActivity) {
activity.page_view.upPageAnim()
}
break
}
}

@ -7,8 +7,10 @@ import android.util.AttributeSet
import android.view.MotionEvent
import android.widget.FrameLayout
import io.legado.app.help.ReadBookConfig
import io.legado.app.ui.widget.page.delegate.CoverPageDelegate
import io.legado.app.ui.widget.page.delegate.PageDelegate
import io.legado.app.ui.widget.page.delegate.SlidePageDelegate
import io.legado.app.utils.getPrefInt
class PageView(context: Context, attrs: AttributeSet) : FrameLayout(context, attrs), PageDelegate.PageInterface {
@ -30,7 +32,7 @@ class PageView(context: Context, attrs: AttributeSet) : FrameLayout(context, att
upBg()
setWillNotDraw(false)
pageDelegate = SlidePageDelegate(this)
upPageAnim()
setPageFactory(TextPageFactory.create(object : DataSource {
override fun pageIndex(): Int {
@ -138,6 +140,13 @@ class PageView(context: Context, attrs: AttributeSet) : FrameLayout(context, att
upContent()
}
fun upPageAnim() {
pageDelegate = when (context.getPrefInt("pageAnim")) {
1 -> SlidePageDelegate(this)
else -> CoverPageDelegate(this)
}
}
fun upContent() {
pageFactory?.let {
prevPage?.setContent(it.previousPage())

@ -13,7 +13,10 @@ import io.legado.app.utils.screenshot
import kotlin.math.abs
abstract class PageDelegate(protected val pageView: PageView) {
val centerRectF = RectF()
val centerRectF = RectF(
pageView.width * 0.33f, pageView.height * 0.33f,
pageView.width * 0.66f, pageView.height * 0.66f
)
//起始点
protected var startX: Float = 0.toFloat()
protected var startY: Float = 0.toFloat()
@ -97,8 +100,8 @@ abstract class PageDelegate(protected val pageView: PageView) {
viewHeight = height
invalidate()
centerRectF.set(
width / 3f, height / 3f,
width * 2f / 3, height * 2f / 3
width * 0.33f, height * 0.33f,
width * 0.66f, height * 0.66f
)
}

Loading…
Cancel
Save