Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -258,7 +258,7 @@ open class GestureHandler {
trackedPointersIDsCount--
}

private fun isTrackingPointer(pointerId: Int) = trackedPointerIDs[pointerId] != -1
fun isTrackingPointer(pointerId: Int) = trackedPointerIDs[pointerId] != -1

private fun needAdapt(event: MotionEvent): Boolean {
if (event.pointerCount != trackedPointersIDsCount) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -533,7 +533,7 @@ class GestureHandlerOrchestrator(
}
}

fun recordHandlerIfNotPresent(handler: GestureHandler, view: View?) {
fun recordHandlerIfNotPresent(handler: GestureHandler, view: View?, pointerId: Int = -1) {
if (gestureHandlers.contains(handler)) {
return
}
Expand All @@ -543,7 +543,9 @@ class GestureHandlerOrchestrator(
handler.activationIndex = Int.MAX_VALUE
handler.prepare(view, this)

if (!handler.shouldBeginWithRecordedHandlers(gestureHandlers)) {
// Only handlers extracted for the same pointer (they already track it) may block this one
val recorded = if (pointerId >= 0) gestureHandlers.filter { it.isTrackingPointer(pointerId) } else emptyList()
if (!handler.shouldBeginWithRecordedHandlers(recorded)) {
handler.cancel()
}
Comment thread
coderabbitai[bot] marked this conversation as resolved.

Expand Down Expand Up @@ -589,7 +591,7 @@ class GestureHandlerOrchestrator(

if (handler.isEnabled && handler.isWithinBounds(view, coords[0], coords[1])) {
found = true
recordHandlerIfNotPresent(handler, parentViewGroup)
recordHandlerIfNotPresent(handler, parentViewGroup, pointerId)
handler.startTrackingPointer(pointerId)
}
}
Expand Down Expand Up @@ -654,7 +656,7 @@ class GestureHandlerOrchestrator(
continue
}

recordHandlerIfNotPresent(handler, view)
recordHandlerIfNotPresent(handler, view, pointerId)
handler.startTrackingPointer(pointerId)
found = true
}
Expand Down Expand Up @@ -691,7 +693,7 @@ class GestureHandlerOrchestrator(
continue
}

recordHandlerIfNotPresent(handler, view)
recordHandlerIfNotPresent(handler, view, pointerId)
handler.startTrackingPointer(pointerId)
found = true
}
Expand Down
Loading