Loading core/java/android/widget/ScrollView.java +49 −21 Original line number Diff line number Diff line Loading @@ -22,6 +22,7 @@ import android.content.Context; import android.content.res.TypedArray; import android.graphics.Rect; import android.util.AttributeSet; import android.util.Log; import android.view.FocusFinder; import android.view.KeyEvent; import android.view.MotionEvent; Loading Loading @@ -51,6 +52,8 @@ import java.util.List; * <p>ScrollView only supports vertical scrolling. */ public class ScrollView extends FrameLayout { private static final String TAG = "ScrollView"; static final int ANIMATED_SCROLL_GAP = 250; static final float MAX_SCROLL_FACTOR = 0.5f; Loading Loading @@ -360,6 +363,17 @@ public class ScrollView extends FrameLayout { return handled; } private boolean inChild(int x, int y) { if (getChildCount() > 0) { final View child = getChildAt(0); return !(y < child.getTop() || y >= child.getBottom() || x < child.getLeft() || x >= child.getRight()); } return false; } @Override public boolean onInterceptTouchEvent(MotionEvent ev) { /* Loading Loading @@ -399,6 +413,11 @@ public class ScrollView extends FrameLayout { break; case MotionEvent.ACTION_DOWN: if (!inChild((int)ev.getX(), (int)y)) { mIsBeingDragged = false; break; } /* Remember location of down touch */ mLastMotionY = y; Loading Loading @@ -451,10 +470,16 @@ public class ScrollView extends FrameLayout { mScroller.abortAnimation(); } if (!inChild((int)ev.getX(), (int)y)) { mIsBeingDragged = false; return false; } // Remember where the motion event started mLastMotionY = y; break; case MotionEvent.ACTION_MOVE: if (mIsBeingDragged) { // Scroll to follow the motion event final int deltaY = (int) (mLastMotionY - y); mLastMotionY = y; Loading @@ -462,7 +487,9 @@ public class ScrollView extends FrameLayout { overscrollBy(0, deltaY, 0, mScrollY, 0, getScrollRange(), 0, getOverscrollMax()); break; } case MotionEvent.ACTION_UP: if (mIsBeingDragged) { final VelocityTracker velocityTracker = mVelocityTracker; velocityTracker.computeCurrentVelocity(1000, mMaximumVelocity); int initialVelocity = (int) velocityTracker.getYVelocity(); Loading @@ -483,6 +510,7 @@ public class ScrollView extends FrameLayout { mVelocityTracker = null; } } } return true; } Loading Loading
core/java/android/widget/ScrollView.java +49 −21 Original line number Diff line number Diff line Loading @@ -22,6 +22,7 @@ import android.content.Context; import android.content.res.TypedArray; import android.graphics.Rect; import android.util.AttributeSet; import android.util.Log; import android.view.FocusFinder; import android.view.KeyEvent; import android.view.MotionEvent; Loading Loading @@ -51,6 +52,8 @@ import java.util.List; * <p>ScrollView only supports vertical scrolling. */ public class ScrollView extends FrameLayout { private static final String TAG = "ScrollView"; static final int ANIMATED_SCROLL_GAP = 250; static final float MAX_SCROLL_FACTOR = 0.5f; Loading Loading @@ -360,6 +363,17 @@ public class ScrollView extends FrameLayout { return handled; } private boolean inChild(int x, int y) { if (getChildCount() > 0) { final View child = getChildAt(0); return !(y < child.getTop() || y >= child.getBottom() || x < child.getLeft() || x >= child.getRight()); } return false; } @Override public boolean onInterceptTouchEvent(MotionEvent ev) { /* Loading Loading @@ -399,6 +413,11 @@ public class ScrollView extends FrameLayout { break; case MotionEvent.ACTION_DOWN: if (!inChild((int)ev.getX(), (int)y)) { mIsBeingDragged = false; break; } /* Remember location of down touch */ mLastMotionY = y; Loading Loading @@ -451,10 +470,16 @@ public class ScrollView extends FrameLayout { mScroller.abortAnimation(); } if (!inChild((int)ev.getX(), (int)y)) { mIsBeingDragged = false; return false; } // Remember where the motion event started mLastMotionY = y; break; case MotionEvent.ACTION_MOVE: if (mIsBeingDragged) { // Scroll to follow the motion event final int deltaY = (int) (mLastMotionY - y); mLastMotionY = y; Loading @@ -462,7 +487,9 @@ public class ScrollView extends FrameLayout { overscrollBy(0, deltaY, 0, mScrollY, 0, getScrollRange(), 0, getOverscrollMax()); break; } case MotionEvent.ACTION_UP: if (mIsBeingDragged) { final VelocityTracker velocityTracker = mVelocityTracker; velocityTracker.computeCurrentVelocity(1000, mMaximumVelocity); int initialVelocity = (int) velocityTracker.getYVelocity(); Loading @@ -483,6 +510,7 @@ public class ScrollView extends FrameLayout { mVelocityTracker = null; } } } return true; } Loading