From 2b5655e8589069f3b3e581cf4ad8e86d00e67909 Mon Sep 17 00:00:00 2001 From: Robert Snoeberger Date: Fri, 2 Oct 2020 16:39:47 -0400 Subject: [PATCH] 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 --- .../android/systemui/media/MediaCarouselScrollHandler.kt | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/packages/SystemUI/src/com/android/systemui/media/MediaCarouselScrollHandler.kt b/packages/SystemUI/src/com/android/systemui/media/MediaCarouselScrollHandler.kt index d80aafb714d30..cb14f31abd160 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 @@ class MediaCarouselScrollHandler( 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 @@ class MediaCarouselScrollHandler( } } } -} \ No newline at end of file +}