Skip to content

Commit b0c71eb

Browse files
author
Jeff Brown
committed
Can't stop the fling!
Bug: 5335420 Fixed a bug in VelocityTracker where the output velocity was not being set to zero when not available. Added a condition to ensure that the velocity is at least the minimum fling velocity before continuing. If not, then the user is trying to stop the fling and scroll more precisely. Change-Id: I36634b0c3f7a9a09cf20c33f71d41163a8e33eed
1 parent 1afeea0 commit b0c71eb

File tree

3 files changed

+5
-2
lines changed

3 files changed

+5
-2
lines changed

core/java/android/widget/AbsListView.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3654,7 +3654,8 @@ public void run() {
36543654
vt.computeCurrentVelocity(1000, mMaximumVelocity);
36553655
final float yvel = -vt.getYVelocity(activeId);
36563656

3657-
if (scroller.isScrollingInDirection(0, yvel)) {
3657+
if (Math.abs(yvel) >= mMinimumVelocity
3658+
&& scroller.isScrollingInDirection(0, yvel)) {
36583659
// Keep the fling alive a little longer
36593660
postDelayed(this, FLYWHEEL_TIMEOUT);
36603661
} else {

core/java/android/widget/OverScroller.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -532,7 +532,7 @@ public boolean isScrollingInDirection(float xvel, float yvel) {
532532
final int dx = mScrollerX.mFinal - mScrollerX.mStart;
533533
final int dy = mScrollerY.mFinal - mScrollerY.mStart;
534534
return !isFinished() && Math.signum(xvel) == Math.signum(dx) &&
535-
Math.signum(yvel) == Math.signum(dy);
535+
Math.signum(yvel) == Math.signum(dy);
536536
}
537537

538538
static class SplineOverScroller {

libs/ui/Input.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1020,6 +1020,8 @@ bool VelocityTracker::getVelocity(uint32_t id, float* outVx, float* outVy) const
10201020
return true;
10211021
}
10221022
}
1023+
*outVx = 0;
1024+
*outVy = 0;
10231025
return false;
10241026
}
10251027

0 commit comments

Comments
 (0)