private final int[] mScrollOffset = new int[2];
private final int[] mScrollConsumed = new int[2];
+ // Used for offsetting MotionEvents that we feed to the VelocityTracker.
+ // In the future it would be nice to be able to give this to the VelocityTracker
+ // directly, or alternatively put a VT into absolute-positioning mode that only
+ // reads the raw screen-coordinate x/y values.
+ private int mNestedYOffset = 0;
+
// True when the popup should be hidden because of a call to
// dispatchDisplayHint()
private boolean mPopupHidden;
scrollConsumedCorrection = mScrollConsumed[1];
if (vtev != null) {
vtev.offsetLocation(0, mScrollOffset[1]);
+ mNestedYOffset += mScrollOffset[1];
}
}
final int deltaY = rawDeltaY;
lastYCorrection -= mScrollOffset[1];
if (vtev != null) {
vtev.offsetLocation(0, mScrollOffset[1]);
+ mNestedYOffset += mScrollOffset[1];
}
} else {
final boolean atOverscrollEdge = overScrollBy(0, overscroll,
final MotionEvent vtev = MotionEvent.obtain(ev);
final int actionMasked = ev.getActionMasked();
+ if (actionMasked == MotionEvent.ACTION_DOWN) {
+ mNestedYOffset = 0;
+ }
+ vtev.offsetLocation(0, mNestedYOffset);
switch (actionMasked) {
case MotionEvent.ACTION_DOWN: {
onTouchDown(ev);
@Override
public boolean onInterceptTouchEvent(MotionEvent ev) {
- int action = ev.getAction();
+ final int actionMasked = ev.getActionMasked();
View v;
if (mPositionScroller != null) {
return true;
}
- switch (action & MotionEvent.ACTION_MASK) {
+ switch (actionMasked) {
case MotionEvent.ACTION_DOWN: {
int touchMode = mTouchMode;
if (touchMode == TOUCH_MODE_OVERFLING || touchMode == TOUCH_MODE_OVERSCROLL) {
mLastY = Integer.MIN_VALUE;
initOrResetVelocityTracker();
mVelocityTracker.addMovement(ev);
+ mNestedYOffset = 0;
startNestedScroll(SCROLL_AXIS_VERTICAL);
if (touchMode == TOUCH_MODE_FLING) {
return true;
*/
private final int[] mScrollOffset = new int[2];
private final int[] mScrollConsumed = new int[2];
+ private int mNestedYOffset;
/**
* The StrictMode "critical time span" objects to catch animation
mLastMotionY = y;
initVelocityTrackerIfNotExists();
mVelocityTracker.addMovement(ev);
+ mNestedYOffset = 0;
if (mScrollStrictSpan == null) {
mScrollStrictSpan = StrictMode.enterCriticalSpan("ScrollView-scroll");
}
MotionEvent vtev = MotionEvent.obtain(ev);
- final int action = ev.getAction();
+ final int actionMasked = ev.getActionMasked();
- switch (action & MotionEvent.ACTION_MASK) {
+ if (actionMasked == MotionEvent.ACTION_DOWN) {
+ mNestedYOffset = 0;
+ }
+ vtev.offsetLocation(0, mNestedYOffset);
+
+ switch (actionMasked) {
case MotionEvent.ACTION_DOWN: {
if (getChildCount() == 0) {
return false;
if (dispatchNestedPreScroll(0, deltaY, mScrollConsumed, mScrollOffset)) {
deltaY -= mScrollConsumed[1];
vtev.offsetLocation(0, mScrollOffset[1]);
+ mNestedYOffset += mScrollOffset[1];
}
if (!mIsBeingDragged && Math.abs(deltaY) > mTouchSlop) {
final ViewParent parent = getParent();
if (dispatchNestedScroll(0, scrolledDeltaY, 0, unconsumedY, mScrollOffset)) {
mLastMotionY -= mScrollOffset[1];
vtev.offsetLocation(0, mScrollOffset[1]);
+ mNestedYOffset += mScrollOffset[1];
} else if (canOverscroll) {
final int pulledToY = oldY + deltaY;
if (pulledToY < 0) {