Merge "Release stretch overscroll when new items are added." into sc-v2-dev am: f0786d5d90
Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/16468159 Change-Id: Ib03a37982c6921d0325f1fea2e03c8b50bf305c3
This commit is contained in:
@@ -3682,14 +3682,14 @@ public abstract class AbsListView extends AdapterView<ListAdapter> implements Te
|
|||||||
if (!mEdgeGlowBottom.isFinished()) {
|
if (!mEdgeGlowBottom.isFinished()) {
|
||||||
mEdgeGlowBottom.onRelease();
|
mEdgeGlowBottom.onRelease();
|
||||||
}
|
}
|
||||||
invalidateTopGlow();
|
invalidateEdgeEffects();
|
||||||
} else if (incrementalDeltaY < 0) {
|
} else if (incrementalDeltaY < 0) {
|
||||||
mEdgeGlowBottom.onPullDistance((float) overscroll / getHeight(),
|
mEdgeGlowBottom.onPullDistance((float) overscroll / getHeight(),
|
||||||
1.f - (float) x / getWidth());
|
1.f - (float) x / getWidth());
|
||||||
if (!mEdgeGlowTop.isFinished()) {
|
if (!mEdgeGlowTop.isFinished()) {
|
||||||
mEdgeGlowTop.onRelease();
|
mEdgeGlowTop.onRelease();
|
||||||
}
|
}
|
||||||
invalidateBottomGlow();
|
invalidateEdgeEffects();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -3729,7 +3729,7 @@ public abstract class AbsListView extends AdapterView<ListAdapter> implements Te
|
|||||||
if (!mEdgeGlowBottom.isFinished()) {
|
if (!mEdgeGlowBottom.isFinished()) {
|
||||||
mEdgeGlowBottom.onRelease();
|
mEdgeGlowBottom.onRelease();
|
||||||
}
|
}
|
||||||
invalidateTopGlow();
|
invalidateEdgeEffects();
|
||||||
} else if (rawDeltaY < 0) {
|
} else if (rawDeltaY < 0) {
|
||||||
mEdgeGlowBottom.onPullDistance(
|
mEdgeGlowBottom.onPullDistance(
|
||||||
(float) -overScrollDistance / getHeight(),
|
(float) -overScrollDistance / getHeight(),
|
||||||
@@ -3737,7 +3737,7 @@ public abstract class AbsListView extends AdapterView<ListAdapter> implements Te
|
|||||||
if (!mEdgeGlowTop.isFinished()) {
|
if (!mEdgeGlowTop.isFinished()) {
|
||||||
mEdgeGlowTop.onRelease();
|
mEdgeGlowTop.onRelease();
|
||||||
}
|
}
|
||||||
invalidateBottomGlow();
|
invalidateEdgeEffects();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -3783,17 +3783,21 @@ public abstract class AbsListView extends AdapterView<ListAdapter> implements Te
|
|||||||
// First allow releasing existing overscroll effect:
|
// First allow releasing existing overscroll effect:
|
||||||
float consumed = 0;
|
float consumed = 0;
|
||||||
if (mEdgeGlowTop.getDistance() != 0) {
|
if (mEdgeGlowTop.getDistance() != 0) {
|
||||||
consumed = mEdgeGlowTop.onPullDistance((float) deltaY / getHeight(),
|
if (canScrollUp()) {
|
||||||
(float) x / getWidth());
|
mEdgeGlowTop.onRelease();
|
||||||
if (consumed != 0f) {
|
} else {
|
||||||
invalidateTopGlow();
|
consumed = mEdgeGlowTop.onPullDistance((float) deltaY / getHeight(),
|
||||||
|
(float) x / getWidth());
|
||||||
}
|
}
|
||||||
|
invalidateEdgeEffects();
|
||||||
} else if (mEdgeGlowBottom.getDistance() != 0) {
|
} else if (mEdgeGlowBottom.getDistance() != 0) {
|
||||||
consumed = -mEdgeGlowBottom.onPullDistance((float) -deltaY / getHeight(),
|
if (canScrollDown()) {
|
||||||
1f - (float) x / getWidth());
|
mEdgeGlowBottom.onRelease();
|
||||||
if (consumed != 0f) {
|
} else {
|
||||||
invalidateBottomGlow();
|
consumed = -mEdgeGlowBottom.onPullDistance((float) -deltaY / getHeight(),
|
||||||
|
1f - (float) x / getWidth());
|
||||||
}
|
}
|
||||||
|
invalidateEdgeEffects();
|
||||||
}
|
}
|
||||||
int pixelsConsumed = Math.round(consumed * getHeight());
|
int pixelsConsumed = Math.round(consumed * getHeight());
|
||||||
return deltaY - pixelsConsumed;
|
return deltaY - pixelsConsumed;
|
||||||
@@ -3803,30 +3807,16 @@ public abstract class AbsListView extends AdapterView<ListAdapter> implements Te
|
|||||||
* @return <code>true</code> if either the top or bottom edge glow is currently active or
|
* @return <code>true</code> if either the top or bottom edge glow is currently active or
|
||||||
* <code>false</code> if it has no value to release.
|
* <code>false</code> if it has no value to release.
|
||||||
*/
|
*/
|
||||||
private boolean isGlowActive() {
|
private boolean doesTouchStopStretch() {
|
||||||
return mEdgeGlowBottom.getDistance() != 0 || mEdgeGlowTop.getDistance() != 0;
|
return (mEdgeGlowBottom.getDistance() != 0 && !canScrollDown())
|
||||||
|
|| (mEdgeGlowTop.getDistance() != 0 && !canScrollUp());
|
||||||
}
|
}
|
||||||
|
|
||||||
private void invalidateTopGlow() {
|
private void invalidateEdgeEffects() {
|
||||||
if (!shouldDisplayEdgeEffects()) {
|
if (!shouldDisplayEdgeEffects()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
final boolean clipToPadding = getClipToPadding();
|
invalidate();
|
||||||
final int top = clipToPadding ? mPaddingTop : 0;
|
|
||||||
final int left = clipToPadding ? mPaddingLeft : 0;
|
|
||||||
final int right = clipToPadding ? getWidth() - mPaddingRight : getWidth();
|
|
||||||
invalidate(left, top, right, top + mEdgeGlowTop.getMaxHeight());
|
|
||||||
}
|
|
||||||
|
|
||||||
private void invalidateBottomGlow() {
|
|
||||||
if (!shouldDisplayEdgeEffects()) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
final boolean clipToPadding = getClipToPadding();
|
|
||||||
final int bottom = clipToPadding ? getHeight() - mPaddingBottom : getHeight();
|
|
||||||
final int left = clipToPadding ? mPaddingLeft : 0;
|
|
||||||
final int right = clipToPadding ? getWidth() - mPaddingRight : getWidth();
|
|
||||||
invalidate(left, bottom - mEdgeGlowBottom.getMaxHeight(), right, bottom);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -4469,7 +4459,7 @@ public abstract class AbsListView extends AdapterView<ListAdapter> implements Te
|
|||||||
final int edgeY = Math.min(0, scrollY + mFirstPositionDistanceGuess) + translateY;
|
final int edgeY = Math.min(0, scrollY + mFirstPositionDistanceGuess) + translateY;
|
||||||
canvas.translate(translateX, edgeY);
|
canvas.translate(translateX, edgeY);
|
||||||
if (mEdgeGlowTop.draw(canvas)) {
|
if (mEdgeGlowTop.draw(canvas)) {
|
||||||
invalidateTopGlow();
|
invalidateEdgeEffects();
|
||||||
}
|
}
|
||||||
canvas.restoreToCount(restoreCount);
|
canvas.restoreToCount(restoreCount);
|
||||||
}
|
}
|
||||||
@@ -4483,7 +4473,7 @@ public abstract class AbsListView extends AdapterView<ListAdapter> implements Te
|
|||||||
canvas.translate(edgeX, edgeY);
|
canvas.translate(edgeX, edgeY);
|
||||||
canvas.rotate(180, width, 0);
|
canvas.rotate(180, width, 0);
|
||||||
if (mEdgeGlowBottom.draw(canvas)) {
|
if (mEdgeGlowBottom.draw(canvas)) {
|
||||||
invalidateBottomGlow();
|
invalidateEdgeEffects();
|
||||||
}
|
}
|
||||||
canvas.restoreToCount(restoreCount);
|
canvas.restoreToCount(restoreCount);
|
||||||
}
|
}
|
||||||
@@ -4573,7 +4563,7 @@ public abstract class AbsListView extends AdapterView<ListAdapter> implements Te
|
|||||||
mActivePointerId = ev.getPointerId(0);
|
mActivePointerId = ev.getPointerId(0);
|
||||||
|
|
||||||
int motionPosition = findMotionRow(y);
|
int motionPosition = findMotionRow(y);
|
||||||
if (isGlowActive()) {
|
if (doesTouchStopStretch()) {
|
||||||
// Pressed during edge effect, so this is considered the same as a fling catch.
|
// Pressed during edge effect, so this is considered the same as a fling catch.
|
||||||
touchMode = mTouchMode = TOUCH_MODE_FLING;
|
touchMode = mTouchMode = TOUCH_MODE_FLING;
|
||||||
} else if (touchMode != TOUCH_MODE_FLING && motionPosition >= 0) {
|
} else if (touchMode != TOUCH_MODE_FLING && motionPosition >= 0) {
|
||||||
@@ -6579,7 +6569,7 @@ public abstract class AbsListView extends AdapterView<ListAdapter> implements Te
|
|||||||
*/
|
*/
|
||||||
public void setBottomEdgeEffectColor(@ColorInt int color) {
|
public void setBottomEdgeEffectColor(@ColorInt int color) {
|
||||||
mEdgeGlowBottom.setColor(color);
|
mEdgeGlowBottom.setColor(color);
|
||||||
invalidateBottomGlow();
|
invalidateEdgeEffects();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -6593,7 +6583,7 @@ public abstract class AbsListView extends AdapterView<ListAdapter> implements Te
|
|||||||
*/
|
*/
|
||||||
public void setTopEdgeEffectColor(@ColorInt int color) {
|
public void setTopEdgeEffectColor(@ColorInt int color) {
|
||||||
mEdgeGlowTop.setColor(color);
|
mEdgeGlowTop.setColor(color);
|
||||||
invalidateTopGlow();
|
invalidateEdgeEffects();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
Reference in New Issue
Block a user