pull/1903/head
kunfei 2 years ago
parent f1938757da
commit d0c6e3fb1c
  1. 22
      app/src/main/java/io/legado/app/ui/book/read/page/PageView.kt
  2. 3
      app/src/main/java/io/legado/app/ui/book/read/page/ReadView.kt

@ -10,12 +10,10 @@ import androidx.core.view.isGone
import androidx.core.view.isInvisible import androidx.core.view.isInvisible
import io.legado.app.R import io.legado.app.R
import io.legado.app.constant.AppConst.timeFormat import io.legado.app.constant.AppConst.timeFormat
import io.legado.app.constant.AppLog
import io.legado.app.data.entities.Bookmark import io.legado.app.data.entities.Bookmark
import io.legado.app.databinding.ViewBookPageBinding import io.legado.app.databinding.ViewBookPageBinding
import io.legado.app.help.config.ReadBookConfig import io.legado.app.help.config.ReadBookConfig
import io.legado.app.help.config.ReadTipConfig import io.legado.app.help.config.ReadTipConfig
import io.legado.app.help.coroutine.Coroutine
import io.legado.app.model.ReadBook import io.legado.app.model.ReadBook
import io.legado.app.ui.book.read.ReadBookActivity import io.legado.app.ui.book.read.ReadBookActivity
import io.legado.app.ui.book.read.page.entities.TextPage import io.legado.app.ui.book.read.page.entities.TextPage
@ -44,8 +42,6 @@ class PageView(context: Context) : FrameLayout(context) {
private var tvTimeBattery: BatteryView? = null private var tvTimeBattery: BatteryView? = null
private var tvTimeBatteryP: BatteryView? = null private var tvTimeBatteryP: BatteryView? = null
private var bitmap: Bitmap? = null
val headerHeight: Int val headerHeight: Int
get() { get() {
val h1 = if (ReadBookConfig.hideStatusBar) 0 else context.statusBarHeight val h1 = if (ReadBookConfig.hideStatusBar) 0 else context.statusBarHeight
@ -65,21 +61,7 @@ class PageView(context: Context) : FrameLayout(context) {
} }
fun getBitmap(): Bitmap? { fun getBitmap(): Bitmap? {
return bitmap?.copy(Bitmap.Config.ARGB_8888, false) return drawingCache?.copy(Bitmap.Config.ARGB_8888, false)
}
private fun upBitmap() {
post {
Coroutine.async {
screenshot()
}.onSuccess {
val tmp = bitmap
bitmap = it
tmp?.recycle()
}.onError {
AppLog.put("更新PageView图片出错", it)
}
}
} }
fun upStyle() = binding.run { fun upStyle() = binding.run {
@ -248,7 +230,6 @@ class PageView(context: Context) : FrameLayout(context) {
val time = timeFormat.format(Date(System.currentTimeMillis())) val time = timeFormat.format(Date(System.currentTimeMillis()))
tvTimeBattery?.setBattery(battery, time) tvTimeBattery?.setBattery(battery, time)
tvTimeBatteryP?.text = "$time $battery%" tvTimeBatteryP?.text = "$time $battery%"
upBitmap()
} }
fun setContent(textPage: TextPage, resetPageOffset: Boolean = true) { fun setContent(textPage: TextPage, resetPageOffset: Boolean = true) {
@ -257,7 +238,6 @@ class PageView(context: Context) : FrameLayout(context) {
resetPageOffset() resetPageOffset()
} }
binding.contentTextView.setContent(textPage) binding.contentTextView.setContent(textPage)
upBitmap()
} }
fun setContentDescription(content: String) { fun setContentDescription(content: String) {

@ -439,6 +439,9 @@ class ReadView(context: Context, attrs: AttributeSet) :
fun upPageAnim() { fun upPageAnim() {
isScroll = ReadBook.pageAnim() == 3 isScroll = ReadBook.pageAnim() == 3
prevPage.isDrawingCacheEnabled = !isScroll
curPage.isDrawingCacheEnabled = !isScroll
nextPage.isDrawingCacheEnabled = !isScroll
ChapterProvider.upLayout() ChapterProvider.upLayout()
when (ReadBook.pageAnim()) { when (ReadBook.pageAnim()) {
PageAnim.coverPageAnim -> if (pageDelegate !is CoverPageDelegate) { PageAnim.coverPageAnim -> if (pageDelegate !is CoverPageDelegate) {

Loading…
Cancel
Save