@@ -309,8 +309,18 @@ public void getClippingRect(Rect outClippingRect) {
309
309
310
310
@ Override
311
311
public void fling (int velocityY ) {
312
+ // Workaround.
313
+ // On Android P if a ScrollView is inverted, we will get a wrong sign for
314
+ // velocityY (see https://issuetracker.google.com/issues/112385925).
315
+ // At the same time, mOnScrollDispatchHelper tracks the correct velocity direction.
316
+ //
317
+ // Hence, we can use the absolute value from whatever the OS gives
318
+ // us and use the sign of what mOnScrollDispatchHelper has tracked.
319
+ final int correctedVelocityY = (int )(Math .abs (velocityY ) * Math .signum (mOnScrollDispatchHelper .getYFlingVelocity ()));
320
+
321
+
312
322
if (mPagingEnabled ) {
313
- flingAndSnap (velocityY );
323
+ flingAndSnap (correctedVelocityY );
314
324
} else if (mScroller != null ) {
315
325
// FB SCROLLVIEW CHANGE
316
326
@@ -326,7 +336,7 @@ public void fling(int velocityY) {
326
336
getScrollX (), // startX
327
337
getScrollY (), // startY
328
338
0 , // velocityX
329
- velocityY , // velocityY
339
+ correctedVelocityY , // velocityY
330
340
0 , // minX
331
341
0 , // maxX
332
342
0 , // minY
@@ -339,9 +349,9 @@ public void fling(int velocityY) {
339
349
340
350
// END FB SCROLLVIEW CHANGE
341
351
} else {
342
- super .fling (velocityY );
352
+ super .fling (correctedVelocityY );
343
353
}
344
- handlePostTouchScrolling (0 , velocityY );
354
+ handlePostTouchScrolling (0 , correctedVelocityY );
345
355
}
346
356
347
357
private void enableFpsListener () {
0 commit comments