pull/517/head
gedoor 4 years ago
parent e34eb8417c
commit 82ca16cb38
  1. 2
      app/src/main/java/io/legado/app/ui/book/read/page/ContentView.kt
  2. 6
      app/src/main/java/io/legado/app/ui/book/read/page/PageView.kt

@ -42,6 +42,7 @@ class ContentView(context: Context) : FrameLayout(context) {
} }
init { init {
if (!isInEditMode) {
//设置背景防止切换背景时文字重叠 //设置背景防止切换背景时文字重叠
setBackgroundColor(context.getCompatColor(R.color.background)) setBackgroundColor(context.getCompatColor(R.color.background))
inflate(context, R.layout.view_book_page, this) inflate(context, R.layout.view_book_page, this)
@ -51,6 +52,7 @@ class ContentView(context: Context) : FrameLayout(context) {
setProgress(it) setProgress(it)
} }
} }
}
fun upStyle() = ReadBookConfig.apply { fun upStyle() = ReadBookConfig.apply {
bv_header_left.typeface = ChapterProvider.typeface bv_header_left.typeface = ChapterProvider.typeface

@ -36,7 +36,7 @@ class PageView(context: Context, attrs: AttributeSet) :
field = value field = value
upContent() upContent()
} }
var isScroll = ReadBook.pageAnim() == 3 var isScroll = false
var prevPage: ContentView = ContentView(context) var prevPage: ContentView = ContentView(context)
var curPage: ContentView = ContentView(context) var curPage: ContentView = ContentView(context)
var nextPage: ContentView = ContentView(context) var nextPage: ContentView = ContentView(context)
@ -95,10 +95,12 @@ class PageView(context: Context, attrs: AttributeSet) :
addView(nextPage) addView(nextPage)
addView(curPage) addView(curPage)
addView(prevPage) addView(prevPage)
if (!isInEditMode) {
upBg() upBg()
setWillNotDraw(false) setWillNotDraw(false)
upPageAnim() upPageAnim()
} }
}
override fun onSizeChanged(w: Int, h: Int, oldw: Int, oldh: Int) { override fun onSizeChanged(w: Int, h: Int, oldw: Int, oldh: Int) {
super.onSizeChanged(w, h, oldw, oldh) super.onSizeChanged(w, h, oldw, oldh)
@ -118,7 +120,7 @@ class PageView(context: Context, attrs: AttributeSet) :
override fun dispatchDraw(canvas: Canvas) { override fun dispatchDraw(canvas: Canvas) {
super.dispatchDraw(canvas) super.dispatchDraw(canvas)
pageDelegate?.onDraw(canvas) pageDelegate?.onDraw(canvas)
if (callBack.isAutoPage && !isScroll) { if (!isInEditMode && callBack.isAutoPage && !isScroll) {
nextPage.screenshot()?.let { nextPage.screenshot()?.let {
val bottom = val bottom =
page_view.height * callBack.autoPageProgress / (ReadBookConfig.autoReadSpeed * 50) page_view.height * callBack.autoPageProgress / (ReadBookConfig.autoReadSpeed * 50)

Loading…
Cancel
Save