mirror of
https://github.com/mihonapp/mihon.git
synced 2025-11-15 13:37:29 +01:00
Stop tap zones from triggering when scrolling is stopped by tapping (#2680)
This commit is contained in:
@@ -10,6 +10,10 @@ The format is a modified version of [Keep a Changelog](https://keepachangelog.co
|
|||||||
- `Fixed` - for any bug fixes.
|
- `Fixed` - for any bug fixes.
|
||||||
- `Other` - for technical stuff.
|
- `Other` - for technical stuff.
|
||||||
|
|
||||||
|
## [Unreleased]
|
||||||
|
### Fixed
|
||||||
|
- Fix reader tap zones triggering after scrolling is stopped by tapping ([@NGB-Was-Taken](https://github.com/NGB-Was-Taken)) ([#2680](https://github.com/mihonapp/mihon/pull/2680))
|
||||||
|
|
||||||
## [v0.19.3] - 2025-11-07
|
## [v0.19.3] - 2025-11-07
|
||||||
### Improved
|
### Improved
|
||||||
- Improved various aspects of the WebView multi window support ([@TheUnlocked](https://github.com/TheUnlocked)) ([#2662](https://github.com/mihonapp/mihon/pull/2662))
|
- Improved various aspects of the WebView multi window support ([@TheUnlocked](https://github.com/TheUnlocked)) ([#2662](https://github.com/mihonapp/mihon/pull/2662))
|
||||||
|
|||||||
@@ -103,6 +103,7 @@ class WebtoonFrame(context: Context) : FrameLayout(context) {
|
|||||||
velocityX: Float,
|
velocityX: Float,
|
||||||
velocityY: Float,
|
velocityY: Float,
|
||||||
): Boolean {
|
): Boolean {
|
||||||
|
recycler?.onManualScroll()
|
||||||
return recycler?.zoomFling(velocityX.toInt(), velocityY.toInt()) ?: false
|
return recycler?.zoomFling(velocityX.toInt(), velocityY.toInt()) ?: false
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -52,6 +52,9 @@ class WebtoonRecyclerView @JvmOverloads constructor(
|
|||||||
var tapListener: ((MotionEvent) -> Unit)? = null
|
var tapListener: ((MotionEvent) -> Unit)? = null
|
||||||
var longTapListener: ((MotionEvent) -> Boolean)? = null
|
var longTapListener: ((MotionEvent) -> Boolean)? = null
|
||||||
|
|
||||||
|
private var isManuallyScrolling = false
|
||||||
|
private var tapDuringManualScroll = false
|
||||||
|
|
||||||
override fun onMeasure(widthSpec: Int, heightSpec: Int) {
|
override fun onMeasure(widthSpec: Int, heightSpec: Int) {
|
||||||
halfWidth = MeasureSpec.getSize(widthSpec) / 2
|
halfWidth = MeasureSpec.getSize(widthSpec) / 2
|
||||||
halfHeight = MeasureSpec.getSize(heightSpec) / 2
|
halfHeight = MeasureSpec.getSize(heightSpec) / 2
|
||||||
@@ -63,6 +66,10 @@ class WebtoonRecyclerView @JvmOverloads constructor(
|
|||||||
}
|
}
|
||||||
|
|
||||||
override fun onTouchEvent(e: MotionEvent): Boolean {
|
override fun onTouchEvent(e: MotionEvent): Boolean {
|
||||||
|
if (e.actionMasked == MotionEvent.ACTION_DOWN) {
|
||||||
|
tapDuringManualScroll = isManuallyScrolling
|
||||||
|
}
|
||||||
|
|
||||||
detector.onTouchEvent(e)
|
detector.onTouchEvent(e)
|
||||||
return super.onTouchEvent(e)
|
return super.onTouchEvent(e)
|
||||||
}
|
}
|
||||||
@@ -82,6 +89,10 @@ class WebtoonRecyclerView @JvmOverloads constructor(
|
|||||||
val totalItemCount = layoutManager?.itemCount ?: 0
|
val totalItemCount = layoutManager?.itemCount ?: 0
|
||||||
atLastPosition = visibleItemCount > 0 && lastVisibleItemPosition == totalItemCount - 1
|
atLastPosition = visibleItemCount > 0 && lastVisibleItemPosition == totalItemCount - 1
|
||||||
atFirstPosition = firstVisibleItemPosition == 0
|
atFirstPosition = firstVisibleItemPosition == 0
|
||||||
|
|
||||||
|
if (state == SCROLL_STATE_IDLE) {
|
||||||
|
isManuallyScrolling = false
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun getPositionX(positionX: Float): Float {
|
private fun getPositionX(positionX: Float): Float {
|
||||||
@@ -212,10 +223,16 @@ class WebtoonRecyclerView @JvmOverloads constructor(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fun onManualScroll() {
|
||||||
|
isManuallyScrolling = true
|
||||||
|
}
|
||||||
|
|
||||||
inner class GestureListener : GestureDetectorWithLongTap.Listener() {
|
inner class GestureListener : GestureDetectorWithLongTap.Listener() {
|
||||||
|
|
||||||
override fun onSingleTapConfirmed(ev: MotionEvent): Boolean {
|
override fun onSingleTapConfirmed(ev: MotionEvent): Boolean {
|
||||||
tapListener?.invoke(ev)
|
if (!tapDuringManualScroll) {
|
||||||
|
tapListener?.invoke(ev)
|
||||||
|
}
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user