Merge pull request #2086 from 821938089/opt-page-anim

优化翻页动画
pull/2088/head
kunfei 2 years ago committed by GitHub
commit 814cfea73b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 2
      app/src/main/java/io/legado/app/ui/book/read/BaseReadBookActivity.kt
  2. 3
      app/src/main/java/io/legado/app/ui/book/read/page/ReadView.kt
  3. 1
      app/src/main/java/io/legado/app/utils/ViewExtensions.kt

@ -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 {

@ -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

@ -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

Loading…
Cancel
Save