mirror of
https://github.com/gedoor/legado.git
synced 2024-08-30 09:23:26 +08:00
优化
This commit is contained in:
parent
f1938757da
commit
d0c6e3fb1c
@ -10,12 +10,10 @@ import androidx.core.view.isGone
|
||||
import androidx.core.view.isInvisible
|
||||
import io.legado.app.R
|
||||
import io.legado.app.constant.AppConst.timeFormat
|
||||
import io.legado.app.constant.AppLog
|
||||
import io.legado.app.data.entities.Bookmark
|
||||
import io.legado.app.databinding.ViewBookPageBinding
|
||||
import io.legado.app.help.config.ReadBookConfig
|
||||
import io.legado.app.help.config.ReadTipConfig
|
||||
import io.legado.app.help.coroutine.Coroutine
|
||||
import io.legado.app.model.ReadBook
|
||||
import io.legado.app.ui.book.read.ReadBookActivity
|
||||
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 tvTimeBatteryP: BatteryView? = null
|
||||
|
||||
private var bitmap: Bitmap? = null
|
||||
|
||||
val headerHeight: Int
|
||||
get() {
|
||||
val h1 = if (ReadBookConfig.hideStatusBar) 0 else context.statusBarHeight
|
||||
@ -65,21 +61,7 @@ class PageView(context: Context) : FrameLayout(context) {
|
||||
}
|
||||
|
||||
fun getBitmap(): Bitmap? {
|
||||
return bitmap?.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)
|
||||
}
|
||||
}
|
||||
return drawingCache?.copy(Bitmap.Config.ARGB_8888, false)
|
||||
}
|
||||
|
||||
fun upStyle() = binding.run {
|
||||
@ -248,7 +230,6 @@ class PageView(context: Context) : FrameLayout(context) {
|
||||
val time = timeFormat.format(Date(System.currentTimeMillis()))
|
||||
tvTimeBattery?.setBattery(battery, time)
|
||||
tvTimeBatteryP?.text = "$time $battery%"
|
||||
upBitmap()
|
||||
}
|
||||
|
||||
fun setContent(textPage: TextPage, resetPageOffset: Boolean = true) {
|
||||
@ -257,7 +238,6 @@ class PageView(context: Context) : FrameLayout(context) {
|
||||
resetPageOffset()
|
||||
}
|
||||
binding.contentTextView.setContent(textPage)
|
||||
upBitmap()
|
||||
}
|
||||
|
||||
fun setContentDescription(content: String) {
|
||||
|
@ -439,6 +439,9 @@ class ReadView(context: Context, attrs: AttributeSet) :
|
||||
|
||||
fun upPageAnim() {
|
||||
isScroll = ReadBook.pageAnim() == 3
|
||||
prevPage.isDrawingCacheEnabled = !isScroll
|
||||
curPage.isDrawingCacheEnabled = !isScroll
|
||||
nextPage.isDrawingCacheEnabled = !isScroll
|
||||
ChapterProvider.upLayout()
|
||||
when (ReadBook.pageAnim()) {
|
||||
PageAnim.coverPageAnim -> if (pageDelegate !is CoverPageDelegate) {
|
||||
|
Loading…
Reference in New Issue
Block a user