Merge "Fix overscroll doesn't affect scrolling when released" into sc-dev am: ebde5e48e6
Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/14681840 Change-Id: I1b58f59a37e2075b46ef73cb4d8e57fd02f8ed46
This commit is contained in:
@@ -3574,28 +3574,27 @@ public abstract class AbsListView extends AdapterView<ListAdapter> implements Te
|
|||||||
private void scrollIfNeeded(int x, int y, MotionEvent vtev) {
|
private void scrollIfNeeded(int x, int y, MotionEvent vtev) {
|
||||||
int rawDeltaY = y - mMotionY;
|
int rawDeltaY = y - mMotionY;
|
||||||
int scrollOffsetCorrection = 0;
|
int scrollOffsetCorrection = 0;
|
||||||
int scrollConsumedCorrection = 0;
|
|
||||||
if (mLastY == Integer.MIN_VALUE) {
|
if (mLastY == Integer.MIN_VALUE) {
|
||||||
rawDeltaY -= mMotionCorrection;
|
rawDeltaY -= mMotionCorrection;
|
||||||
}
|
}
|
||||||
if (dispatchNestedPreScroll(0, mLastY != Integer.MIN_VALUE ? mLastY - y : -rawDeltaY,
|
|
||||||
mScrollConsumed, mScrollOffset)) {
|
int incrementalDeltaY = mLastY != Integer.MIN_VALUE ? y - mLastY : rawDeltaY;
|
||||||
|
|
||||||
|
// First allow releasing existing overscroll effect:
|
||||||
|
incrementalDeltaY = releaseGlow(incrementalDeltaY, x);
|
||||||
|
|
||||||
|
if (dispatchNestedPreScroll(0, -incrementalDeltaY, mScrollConsumed, mScrollOffset)) {
|
||||||
rawDeltaY += mScrollConsumed[1];
|
rawDeltaY += mScrollConsumed[1];
|
||||||
scrollOffsetCorrection = -mScrollOffset[1];
|
scrollOffsetCorrection = -mScrollOffset[1];
|
||||||
scrollConsumedCorrection = mScrollConsumed[1];
|
incrementalDeltaY += mScrollConsumed[1];
|
||||||
if (vtev != null) {
|
if (vtev != null) {
|
||||||
vtev.offsetLocation(0, mScrollOffset[1]);
|
vtev.offsetLocation(0, mScrollOffset[1]);
|
||||||
mNestedYOffset += mScrollOffset[1];
|
mNestedYOffset += mScrollOffset[1];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
final int deltaY = rawDeltaY;
|
final int deltaY = rawDeltaY;
|
||||||
int incrementalDeltaY =
|
|
||||||
mLastY != Integer.MIN_VALUE ? y - mLastY + scrollConsumedCorrection : deltaY;
|
|
||||||
int lastYCorrection = 0;
|
int lastYCorrection = 0;
|
||||||
|
|
||||||
// First allow releasing existing overscroll effect:
|
|
||||||
incrementalDeltaY = releaseGlow(incrementalDeltaY, x);
|
|
||||||
|
|
||||||
if (mTouchMode == TOUCH_MODE_SCROLL) {
|
if (mTouchMode == TOUCH_MODE_SCROLL) {
|
||||||
if (PROFILE_SCROLLING) {
|
if (PROFILE_SCROLLING) {
|
||||||
if (!mScrollProfilingStarted) {
|
if (!mScrollProfilingStarted) {
|
||||||
|
|||||||
@@ -342,6 +342,9 @@ public class EdgeEffect {
|
|||||||
|
|
||||||
mGlowAlphaFinish = mGlowAlpha;
|
mGlowAlphaFinish = mGlowAlpha;
|
||||||
mGlowScaleYFinish = mGlowScaleY;
|
mGlowScaleYFinish = mGlowScaleY;
|
||||||
|
if (mEdgeEffectType == TYPE_STRETCH && mDistance == 0) {
|
||||||
|
mState = STATE_IDLE;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -739,8 +742,12 @@ public class EdgeEffect {
|
|||||||
private boolean isAtEquilibrium() {
|
private boolean isAtEquilibrium() {
|
||||||
double displacement = mDistance * mHeight; // in pixels
|
double displacement = mDistance * mHeight; // in pixels
|
||||||
double velocity = mVelocity;
|
double velocity = mVelocity;
|
||||||
return Math.abs(velocity) < VELOCITY_THRESHOLD
|
|
||||||
&& Math.abs(displacement) < VALUE_THRESHOLD;
|
// Don't allow displacement to drop below 0. We don't want it stretching the opposite
|
||||||
|
// direction if it is flung that way. We also want to stop the animation as soon as
|
||||||
|
// it gets very close to its destination.
|
||||||
|
return displacement < 0 || (Math.abs(velocity) < VELOCITY_THRESHOLD
|
||||||
|
&& displacement < VALUE_THRESHOLD);
|
||||||
}
|
}
|
||||||
|
|
||||||
private float dampStretchVector(float normalizedVec) {
|
private float dampStretchVector(float normalizedVec) {
|
||||||
|
|||||||
Reference in New Issue
Block a user