summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author omarmt <omarmt@google.com> 2023-12-27 14:52:08 +0000
committer omarmt <omarmt@google.com> 2024-01-11 10:58:24 +0000
commitefcd54b75118a81c91a426de11f01301cc9d99c3 (patch)
tree45c8f1ba0281c7609079255a89ec74f0413e8f4a
parent13158db0c373ef14642946114ecc14a139a8e3f8 (diff)
SceneGestureHandler renamed gestureWithPriority to currentSource
This is just a refactor. Test: STL tests Bug: 317063114 Flag: NA Change-Id: Ia69c3e3fe06808bb5a8f33f1b1090392a025532d
-rw-r--r--packages/SystemUI/compose/scene/src/com/android/compose/animation/scene/SceneGestureHandler.kt20
1 files changed, 12 insertions, 8 deletions
diff --git a/packages/SystemUI/compose/scene/src/com/android/compose/animation/scene/SceneGestureHandler.kt b/packages/SystemUI/compose/scene/src/com/android/compose/animation/scene/SceneGestureHandler.kt
index 64388b7653e0..ff054786cf52 100644
--- a/packages/SystemUI/compose/scene/src/com/android/compose/animation/scene/SceneGestureHandler.kt
+++ b/packages/SystemUI/compose/scene/src/com/android/compose/animation/scene/SceneGestureHandler.kt
@@ -73,7 +73,7 @@ internal class SceneGestureHandler(
private val positionalThreshold
get() = with(layoutImpl.density) { 56.dp.toPx() }
- internal var gestureWithPriority: Any? = null
+ internal var currentSource: Any? = null
/** The [UserAction]s associated to the current swipe. */
private var actionUpOrLeft: UserAction? = null
@@ -520,20 +520,22 @@ internal class SceneGestureHandler(
private class SceneDraggableHandler(
private val gestureHandler: SceneGestureHandler,
) : DraggableHandler {
+ private val source = this
+
override fun onDragStarted(startedPosition: Offset, overSlop: Float, pointersDown: Int) {
- gestureHandler.gestureWithPriority = this
+ gestureHandler.currentSource = source
gestureHandler.onDragStarted(pointersDown, startedPosition, overSlop)
}
override fun onDelta(pixels: Float) {
- if (gestureHandler.gestureWithPriority == this) {
+ if (gestureHandler.currentSource == source) {
gestureHandler.onDrag(delta = pixels)
}
}
override fun onDragStopped(velocity: Float) {
- if (gestureHandler.gestureWithPriority == this) {
- gestureHandler.gestureWithPriority = null
+ if (gestureHandler.currentSource == source) {
+ gestureHandler.currentSource = null
gestureHandler.onDragStopped(velocity = velocity, canChangeScene = true)
}
}
@@ -586,6 +588,8 @@ internal class SceneNestedScrollHandler(
return nextScene != null
}
+ val source = this
+
return PriorityNestedScrollConnection(
orientation = orientation,
canStartPreScroll = { offsetAvailable, offsetBeforeStart ->
@@ -656,7 +660,7 @@ internal class SceneNestedScrollHandler(
canContinueScroll = { true },
canScrollOnFling = false,
onStart = { offsetAvailable ->
- gestureHandler.gestureWithPriority = this
+ gestureHandler.currentSource = source
gestureHandler.onDragStarted(
pointersDown = 1,
startedPosition = null,
@@ -664,7 +668,7 @@ internal class SceneNestedScrollHandler(
)
},
onScroll = { offsetAvailable ->
- if (gestureHandler.gestureWithPriority != this) {
+ if (gestureHandler.currentSource != source) {
return@PriorityNestedScrollConnection 0f
}
@@ -675,7 +679,7 @@ internal class SceneNestedScrollHandler(
offsetAvailable
},
onStop = { velocityAvailable ->
- if (gestureHandler.gestureWithPriority != this) {
+ if (gestureHandler.currentSource != source) {
return@PriorityNestedScrollConnection 0f
}