Fix window size handling in reader
This commit is contained in:
@@ -109,7 +109,7 @@ class ReaderActivity :
|
|||||||
setContentView(ActivityReaderBinding.inflate(layoutInflater))
|
setContentView(ActivityReaderBinding.inflate(layoutInflater))
|
||||||
readerManager = ReaderManager(supportFragmentManager, viewBinding.container, settings)
|
readerManager = ReaderManager(supportFragmentManager, viewBinding.container, settings)
|
||||||
setDisplayHomeAsUp(isEnabled = true, showUpAsClose = false)
|
setDisplayHomeAsUp(isEnabled = true, showUpAsClose = false)
|
||||||
touchHelper = TapGridDispatcher(this, this)
|
touchHelper = TapGridDispatcher(viewBinding.root, this)
|
||||||
scrollTimer = scrollTimerFactory.create(resources, this, this)
|
scrollTimer = scrollTimerFactory.create(resources, this, this)
|
||||||
pageSaveHelper = pageSaveHelperFactory.create(this)
|
pageSaveHelper = pageSaveHelperFactory.create(this)
|
||||||
controlDelegate = ReaderControlDelegate(resources, settings, tapGridSettings, this)
|
controlDelegate = ReaderControlDelegate(resources, settings, tapGridSettings, this)
|
||||||
|
|||||||
@@ -1,19 +1,17 @@
|
|||||||
package org.koitharu.kotatsu.reader.ui.tapgrid
|
package org.koitharu.kotatsu.reader.ui.tapgrid
|
||||||
|
|
||||||
import android.content.Context
|
|
||||||
import android.view.GestureDetector
|
import android.view.GestureDetector
|
||||||
import android.view.MotionEvent
|
import android.view.MotionEvent
|
||||||
|
import android.view.View
|
||||||
import org.koitharu.kotatsu.reader.domain.TapGridArea
|
import org.koitharu.kotatsu.reader.domain.TapGridArea
|
||||||
import kotlin.math.roundToInt
|
import kotlin.math.roundToInt
|
||||||
|
|
||||||
class TapGridDispatcher(
|
class TapGridDispatcher(
|
||||||
context: Context,
|
private val rootView: View,
|
||||||
private val listener: OnGridTouchListener,
|
private val listener: OnGridTouchListener,
|
||||||
) : GestureDetector.SimpleOnGestureListener() {
|
) : GestureDetector.SimpleOnGestureListener() {
|
||||||
|
|
||||||
private val detector = GestureDetector(context, this)
|
private val detector = GestureDetector(rootView.context, this)
|
||||||
private val width = context.resources.displayMetrics.widthPixels
|
|
||||||
private val height = context.resources.displayMetrics.heightPixels
|
|
||||||
private var isDispatching = false
|
private var isDispatching = false
|
||||||
|
|
||||||
init {
|
init {
|
||||||
@@ -49,6 +47,11 @@ class TapGridDispatcher(
|
|||||||
}
|
}
|
||||||
|
|
||||||
private fun getArea(x: Float, y: Float): TapGridArea? {
|
private fun getArea(x: Float, y: Float): TapGridArea? {
|
||||||
|
val width = rootView.width
|
||||||
|
val height = rootView.height
|
||||||
|
if (height <= 0 || width <= 0) {
|
||||||
|
return null
|
||||||
|
}
|
||||||
val xIndex = (x * 2f / width).roundToInt()
|
val xIndex = (x * 2f / width).roundToInt()
|
||||||
val yIndex = (y * 2f / height).roundToInt()
|
val yIndex = (y * 2f / height).roundToInt()
|
||||||
val area = when (xIndex) {
|
val area = when (xIndex) {
|
||||||
|
|||||||
Reference in New Issue
Block a user