优化
This commit is contained in:
@@ -2,7 +2,6 @@ package io.legado.app.ui.book.read.page
|
|||||||
|
|
||||||
import android.annotation.SuppressLint
|
import android.annotation.SuppressLint
|
||||||
import android.content.Context
|
import android.content.Context
|
||||||
import android.graphics.Bitmap
|
|
||||||
import android.graphics.drawable.Drawable
|
import android.graphics.drawable.Drawable
|
||||||
import android.view.LayoutInflater
|
import android.view.LayoutInflater
|
||||||
import android.widget.FrameLayout
|
import android.widget.FrameLayout
|
||||||
@@ -14,7 +13,6 @@ 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
|
||||||
@@ -42,7 +40,6 @@ class PageView(context: Context) : FrameLayout(context) {
|
|||||||
private var tvBookName: BatteryView? = null
|
private var tvBookName: BatteryView? = null
|
||||||
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() {
|
||||||
@@ -62,21 +59,6 @@ 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 {
|
|
||||||
bitmap?.recycle()
|
|
||||||
bitmap = screenshot()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
fun upStyle() = binding.run {
|
fun upStyle() = binding.run {
|
||||||
upTipStyle()
|
upTipStyle()
|
||||||
ReadBookConfig.let {
|
ReadBookConfig.let {
|
||||||
@@ -243,7 +225,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) {
|
||||||
@@ -252,7 +233,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) {
|
||||||
|
|||||||
+5
-4
@@ -4,6 +4,7 @@ import android.graphics.Bitmap
|
|||||||
import android.view.MotionEvent
|
import android.view.MotionEvent
|
||||||
import io.legado.app.ui.book.read.page.ReadView
|
import io.legado.app.ui.book.read.page.ReadView
|
||||||
import io.legado.app.ui.book.read.page.entities.PageDirection
|
import io.legado.app.ui.book.read.page.entities.PageDirection
|
||||||
|
import io.legado.app.utils.screenshot
|
||||||
|
|
||||||
abstract class HorizontalPageDelegate(readView: ReadView) : PageDelegate(readView) {
|
abstract class HorizontalPageDelegate(readView: ReadView) : PageDelegate(readView) {
|
||||||
|
|
||||||
@@ -20,15 +21,15 @@ abstract class HorizontalPageDelegate(readView: ReadView) : PageDelegate(readVie
|
|||||||
when (mDirection) {
|
when (mDirection) {
|
||||||
PageDirection.PREV -> {
|
PageDirection.PREV -> {
|
||||||
prevBitmap?.recycle()
|
prevBitmap?.recycle()
|
||||||
prevBitmap = prevPage.getBitmap()
|
prevBitmap = prevPage.screenshot()
|
||||||
curBitmap?.recycle()
|
curBitmap?.recycle()
|
||||||
curBitmap = curPage.getBitmap()
|
curBitmap = curPage.screenshot()
|
||||||
}
|
}
|
||||||
PageDirection.NEXT -> {
|
PageDirection.NEXT -> {
|
||||||
nextBitmap?.recycle()
|
nextBitmap?.recycle()
|
||||||
nextBitmap = nextPage.getBitmap()
|
nextBitmap = nextPage.screenshot()
|
||||||
curBitmap?.recycle()
|
curBitmap?.recycle()
|
||||||
curBitmap = curPage.getBitmap()
|
curBitmap = curPage.screenshot()
|
||||||
}
|
}
|
||||||
else -> Unit
|
else -> Unit
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user