Skip to content

Commit

Permalink
workaround to wrong fling direction for android P: facebook#21117
Browse files Browse the repository at this point in the history
  • Loading branch information
chrisnojima committed Sep 17, 2018
1 parent 3008c3c commit 7c43cbb
Showing 1 changed file with 10 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -292,6 +292,16 @@ public void getClippingRect(Rect outClippingRect) {

@Override
public void fling(int velocityY) {
// Workaround.
// On Android P if a ScrollView is inverted, we will get a wrong sign for
// velocityY (see https://issuetracker.google.com/issues/112385925).
// At the same time, mOnScrollDispatchHelper tracks the correct velocity direction.
//
// Hence, we can use the absolute value from whatever the OS gives
// us and use the sign of what mOnScrollDispatchHelper has tracked.
velocityY = (int)(Math.abs(velocityY) * Math.signum(mOnScrollDispatchHelper.getYFlingVelocity()));


if (mPagingEnabled) {
smoothScrollAndSnap(velocityY);
} else if (mScroller != null) {
Expand Down

0 comments on commit 7c43cbb

Please sign in to comment.