@Override public boolean onTouchEvent(MotionEvent event) { mScaleGestureDetector.onTouchEvent(event); if (!mScaling) mGestureDetector.onTouchEvent(event); if (event.getActionMasked() == MotionEvent.ACTION_DOWN) { mUserInteracting = true; } if (event.getActionMasked() == MotionEvent.ACTION_UP) { mScrollDisabled = false; mUserInteracting = false; View v = mChildViews.get(mCurrent); if (v != null) { if (mScroller.isFinished()) { // If, at the end of user interaction, there is no // current inertial scroll in operation then animate // the view onto screen if necessary slideViewOntoScreen(v); } if (mScroller.isFinished()) { // If still there is no inertial scroll in operation // then the layout is stable postSettle(v); } } } requestLayout(); return true; }
public void run() { if (!mScroller.isFinished()) { mScroller.computeScrollOffset(); int x = mScroller.getCurrX(); int y = mScroller.getCurrY(); mXScroll += x - mScrollerLastX; mYScroll += y - mScrollerLastY; mScrollerLastX = x; mScrollerLastY = y; requestLayout(); post(this); } else if (!mUserInteracting) { // End of an inertial scroll and the user is not interacting. // The layout is stable View v = mChildViews.get(mCurrent); if (v != null) postSettle(v); } }