@@ -73,7 +73,7 @@ public class ScrollView extends FrameLayout {
7373 /**
7474 * Position of the last motion event.
7575 */
76- private float mLastMotionY ;
76+ private int mLastMotionY ;
7777
7878 /**
7979 * True when the layout has changed but the traversal has not come through yet.
@@ -472,8 +472,8 @@ public boolean onInterceptTouchEvent(MotionEvent ev) {
472472 }
473473
474474 final int pointerIndex = ev .findPointerIndex (activePointerId );
475- final float y = ev .getY (pointerIndex );
476- final int yDiff = ( int ) Math .abs (y - mLastMotionY );
475+ final int y = ( int ) ev .getY (pointerIndex );
476+ final int yDiff = Math .abs (y - mLastMotionY );
477477 if (yDiff > mTouchSlop ) {
478478 mIsBeingDragged = true ;
479479 mLastMotionY = y ;
@@ -487,7 +487,7 @@ public boolean onInterceptTouchEvent(MotionEvent ev) {
487487 }
488488
489489 case MotionEvent .ACTION_DOWN : {
490- final float y = ev .getY ();
490+ final int y = ( int ) ev .getY ();
491491 if (!inChild ((int ) ev .getX (), (int ) y )) {
492492 mIsBeingDragged = false ;
493493 recycleVelocityTracker ();
@@ -522,7 +522,7 @@ public boolean onInterceptTouchEvent(MotionEvent ev) {
522522 mActivePointerId = INVALID_POINTER ;
523523 recycleVelocityTracker ();
524524 if (mScroller .springBack (mScrollX , mScrollY , 0 , 0 , 0 , getScrollRange ())) {
525- invalidate ();
525+ postInvalidateOnAnimation ();
526526 }
527527 break ;
528528 case MotionEvent .ACTION_POINTER_UP :
@@ -564,16 +564,16 @@ public boolean onTouchEvent(MotionEvent ev) {
564564 }
565565
566566 // Remember where the motion event started
567- mLastMotionY = ev .getY ();
567+ mLastMotionY = ( int ) ev .getY ();
568568 mActivePointerId = ev .getPointerId (0 );
569569 break ;
570570 }
571571 case MotionEvent .ACTION_MOVE :
572572 if (mIsBeingDragged ) {
573573 // Scroll to follow the motion event
574574 final int activePointerIndex = ev .findPointerIndex (mActivePointerId );
575- final float y = ev .getY (activePointerIndex );
576- final int deltaY = ( int ) ( mLastMotionY - y ) ;
575+ final int y = ( int ) ev .getY (activePointerIndex );
576+ final int deltaY = mLastMotionY - y ;
577577 mLastMotionY = y ;
578578
579579 final int oldX = mScrollX ;
@@ -605,7 +605,7 @@ public boolean onTouchEvent(MotionEvent ev) {
605605 }
606606 if (mEdgeGlowTop != null
607607 && (!mEdgeGlowTop .isFinished () || !mEdgeGlowBottom .isFinished ())) {
608- invalidate ();
608+ postInvalidateOnAnimation ();
609609 }
610610 }
611611 }
@@ -622,7 +622,7 @@ public boolean onTouchEvent(MotionEvent ev) {
622622 } else {
623623 if (mScroller .springBack (mScrollX , mScrollY , 0 , 0 , 0 ,
624624 getScrollRange ())) {
625- invalidate ();
625+ postInvalidateOnAnimation ();
626626 }
627627 }
628628 }
@@ -634,21 +634,21 @@ public boolean onTouchEvent(MotionEvent ev) {
634634 case MotionEvent .ACTION_CANCEL :
635635 if (mIsBeingDragged && getChildCount () > 0 ) {
636636 if (mScroller .springBack (mScrollX , mScrollY , 0 , 0 , 0 , getScrollRange ())) {
637- invalidate ();
637+ postInvalidateOnAnimation ();
638638 }
639639 mActivePointerId = INVALID_POINTER ;
640640 endDrag ();
641641 }
642642 break ;
643643 case MotionEvent .ACTION_POINTER_DOWN : {
644644 final int index = ev .getActionIndex ();
645- mLastMotionY = ev .getY (index );
645+ mLastMotionY = ( int ) ev .getY (index );
646646 mActivePointerId = ev .getPointerId (index );
647647 break ;
648648 }
649649 case MotionEvent .ACTION_POINTER_UP :
650650 onSecondaryPointerUp (ev );
651- mLastMotionY = ev .getY (ev .findPointerIndex (mActivePointerId ));
651+ mLastMotionY = ( int ) ev .getY (ev .findPointerIndex (mActivePointerId ));
652652 break ;
653653 }
654654 return true ;
@@ -663,7 +663,7 @@ private void onSecondaryPointerUp(MotionEvent ev) {
663663 // active pointer and adjust accordingly.
664664 // TODO: Make this decision more intelligent.
665665 final int newPointerIndex = pointerIndex == 0 ? 1 : 0 ;
666- mLastMotionY = ev .getY (newPointerIndex );
666+ mLastMotionY = ( int ) ev .getY (newPointerIndex );
667667 mActivePointerId = ev .getPointerId (newPointerIndex );
668668 if (mVelocityTracker != null ) {
669669 mVelocityTracker .clear ();
@@ -1047,7 +1047,7 @@ public final void smoothScrollBy(int dx, int dy) {
10471047 dy = Math .max (0 , Math .min (scrollY + dy , maxY )) - scrollY ;
10481048
10491049 mScroller .startScroll (mScrollX , scrollY , 0 , dy );
1050- invalidate ();
1050+ postInvalidateOnAnimation ();
10511051 } else {
10521052 if (!mScroller .isFinished ()) {
10531053 mScroller .abortAnimation ();
@@ -1174,7 +1174,7 @@ public void computeScroll() {
11741174
11751175 if (!awakenScrollBars ()) {
11761176 // Keep on drawing until the animation has finished.
1177- invalidate ();
1177+ postInvalidateOnAnimation ();
11781178 }
11791179 } else {
11801180 if (mFlingStrictSpan != null ) {
@@ -1430,7 +1430,7 @@ public void fling(int velocityY) {
14301430 mFlingStrictSpan = StrictMode .enterCriticalSpan ("ScrollView-fling" );
14311431 }
14321432
1433- invalidate ();
1433+ postInvalidateOnAnimation ();
14341434 }
14351435 }
14361436
@@ -1495,7 +1495,7 @@ public void draw(Canvas canvas) {
14951495 canvas .translate (mPaddingLeft , Math .min (0 , scrollY ));
14961496 mEdgeGlowTop .setSize (width , getHeight ());
14971497 if (mEdgeGlowTop .draw (canvas )) {
1498- invalidate ();
1498+ postInvalidateOnAnimation ();
14991499 }
15001500 canvas .restoreToCount (restoreCount );
15011501 }
@@ -1509,7 +1509,7 @@ public void draw(Canvas canvas) {
15091509 canvas .rotate (180 , width , 0 );
15101510 mEdgeGlowBottom .setSize (width , height );
15111511 if (mEdgeGlowBottom .draw (canvas )) {
1512- invalidate ();
1512+ postInvalidateOnAnimation ();
15131513 }
15141514 canvas .restoreToCount (restoreCount );
15151515 }
0 commit comments