diff --git a/app/src/main/java/io/legado/app/ui/book/read/page/provider/ChapterProvider.kt b/app/src/main/java/io/legado/app/ui/book/read/page/provider/ChapterProvider.kt index f9acd562c..83e6419ca 100644 --- a/app/src/main/java/io/legado/app/ui/book/read/page/provider/ChapterProvider.kt +++ b/app/src/main/java/io/legado/app/ui/book/read/page/provider/ChapterProvider.kt @@ -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)) } /** diff --git a/modules/rhino/src/main/java/com/script/rhino/RhinoClassShutter.kt b/modules/rhino/src/main/java/com/script/rhino/RhinoClassShutter.kt index 3f12769db..ee486e431 100644 --- a/modules/rhino/src/main/java/com/script/rhino/RhinoClassShutter.kt +++ b/modules/rhino/src/main/java/com/script/rhino/RhinoClassShutter.kt @@ -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",