mirror of
https://github.com/gedoor/legado.git
synced 2025-08-10 00:52:30 +00:00
优化
This commit is contained in:
@@ -8,6 +8,7 @@ import android.os.Build
|
||||
import android.text.Layout
|
||||
import android.text.StaticLayout
|
||||
import android.text.TextPaint
|
||||
import androidx.core.os.postDelayed
|
||||
import io.legado.app.constant.AppPattern
|
||||
import io.legado.app.constant.EventBus
|
||||
import io.legado.app.data.entities.Book
|
||||
@@ -24,6 +25,7 @@ import io.legado.app.ui.book.read.page.entities.column.ImageColumn
|
||||
import io.legado.app.ui.book.read.page.entities.column.ReviewColumn
|
||||
import io.legado.app.ui.book.read.page.entities.column.TextColumn
|
||||
import io.legado.app.utils.RealPathUtil
|
||||
import io.legado.app.utils.buildMainHandler
|
||||
import io.legado.app.utils.dpToPx
|
||||
import io.legado.app.utils.fastSum
|
||||
import io.legado.app.utils.isContentScheme
|
||||
@@ -144,6 +146,12 @@ object ChapterProvider {
|
||||
@JvmStatic
|
||||
var visibleRect = RectF()
|
||||
|
||||
private val handler by lazy {
|
||||
buildMainHandler()
|
||||
}
|
||||
|
||||
private var upViewSizeRunnable: Runnable? = null
|
||||
|
||||
init {
|
||||
upStyle()
|
||||
}
|
||||
@@ -946,12 +954,29 @@ object ChapterProvider {
|
||||
* 更新View尺寸
|
||||
*/
|
||||
fun upViewSize(width: Int, height: Int) {
|
||||
if (width > 0 && height > 0 && (width != viewWidth || height != viewHeight)) {
|
||||
viewWidth = width
|
||||
viewHeight = height
|
||||
upLayout()
|
||||
postEvent(EventBus.UP_CONFIG, arrayListOf(5))
|
||||
if (width <= 0 || height <= 0) {
|
||||
return
|
||||
}
|
||||
if (width != viewWidth || height != viewHeight) {
|
||||
if (width == viewWidth) {
|
||||
upViewSizeRunnable = handler.postDelayed(300) {
|
||||
upViewSizeRunnable = null
|
||||
notifyViewSizeChange(width, height)
|
||||
}
|
||||
} else {
|
||||
notifyViewSizeChange(width, height)
|
||||
}
|
||||
} else if (upViewSizeRunnable != null) {
|
||||
handler.removeCallbacks(upViewSizeRunnable!!)
|
||||
upViewSizeRunnable = null
|
||||
}
|
||||
}
|
||||
|
||||
private fun notifyViewSizeChange(width: Int, height: Int) {
|
||||
viewWidth = width
|
||||
viewHeight = height
|
||||
upLayout()
|
||||
postEvent(EventBus.UP_CONFIG, arrayListOf(5))
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -76,6 +76,7 @@ object RhinoClassShutter : ClassShutter {
|
||||
"android.app.ActivityThread",
|
||||
"android.app.AppGlobals",
|
||||
"android.os.Looper",
|
||||
"android.os.Process",
|
||||
|
||||
"cn.hutool.core.lang.JarClassLoader",
|
||||
"cn.hutool.core.lang.Singleton",
|
||||
|
||||
Reference in New Issue
Block a user