优化翻页动画

This commit is contained in:
821938089
2022-07-20 22:22:13 +08:00
parent f04676d21b
commit 98258eefe6
3 changed files with 5 additions and 1 deletions

View File

@@ -198,6 +198,8 @@ abstract class BaseReadBookActivity :
* 保持亮屏
*/
fun keepScreenOn(on: Boolean) {
val isScreenOn = (window.attributes.flags and WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON) != 0
if (on == isScreenOn) return
if (on) {
window.addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON)
} else {

View File

@@ -160,7 +160,6 @@ class ReadView(context: Context, attrs: AttributeSet) :
*/
@SuppressLint("ClickableViewAccessibility")
override fun onTouchEvent(event: MotionEvent): Boolean {
callBack.screenOffTimerStart()
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.R) {
val insets =
this.rootWindowInsets.getInsetsIgnoringVisibility(WindowInsets.Type.mandatorySystemGestures())
@@ -174,6 +173,7 @@ class ReadView(context: Context, attrs: AttributeSet) :
when (event.action) {
MotionEvent.ACTION_DOWN -> {
callBack.screenOffTimerStart()
if (isTextSelected) {
curPage.cancelSelect()
isTextSelected = false
@@ -205,6 +205,7 @@ class ReadView(context: Context, attrs: AttributeSet) :
}
}
MotionEvent.ACTION_UP -> {
callBack.screenOffTimerStart()
removeCallbacks(longPressRunnable)
if (!pressDown) return true
pressDown = false

View File

@@ -133,6 +133,7 @@ fun View.screenshot(): Bitmap? {
c.translate(-scrollX.toFloat(), -scrollY.toFloat())
this.draw(c)
c.setBitmap(null)
screenshot.prepareToDraw()
screenshot
} else {
null