Scroll to correct position on action up or cancel
Since the scroll is being queued on the main executor, use an absolute
position instead of relative position. The scroll position might have
changed by the time the task runs.
Fixes: 164934224
Test: manual - repro steps
Change-Id: Ie1b14743479f81df03030c525e6aebc6a7f8df97
diff --git a/packages/SystemUI/src/com/android/systemui/media/MediaCarouselScrollHandler.kt b/packages/SystemUI/src/com/android/systemui/media/MediaCarouselScrollHandler.kt
index d80aafb..cb14f31 100644
--- a/packages/SystemUI/src/com/android/systemui/media/MediaCarouselScrollHandler.kt
+++ b/packages/SystemUI/src/com/android/systemui/media/MediaCarouselScrollHandler.kt
@@ -282,10 +282,12 @@
scrollXAmount = -1 * relativePos
}
if (scrollXAmount != 0) {
+ val dx = if (isRtl) -scrollXAmount else scrollXAmount
+ val newScrollX = scrollView.relativeScrollX + dx
// Delay the scrolling since scrollView calls springback which cancels
// the animation again..
mainExecutor.execute {
- scrollView.smoothScrollBy(if (isRtl) -scrollXAmount else scrollXAmount, 0)
+ scrollView.smoothScrollTo(newScrollX, scrollView.scrollY)
}
}
val currentTranslation = scrollView.getContentTranslation()
@@ -553,4 +555,4 @@
}
}
}
-}
\ No newline at end of file
+}