Merge "Make ListView's EdgeEffect respect the clipToPadding flag" into mnc-dev
This commit is contained in:
@@ -694,9 +694,6 @@ public abstract class AbsListView extends AdapterView<ListAdapter> implements Te
|
|||||||
*/
|
*/
|
||||||
private boolean mForceTranscriptScroll;
|
private boolean mForceTranscriptScroll;
|
||||||
|
|
||||||
private int mGlowPaddingLeft;
|
|
||||||
private int mGlowPaddingRight;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Used for interacting with list items from an accessibility service.
|
* Used for interacting with list items from an accessibility service.
|
||||||
*/
|
*/
|
||||||
@@ -3489,17 +3486,14 @@ public abstract class AbsListView extends AdapterView<ListAdapter> implements Te
|
|||||||
if (!mEdgeGlowBottom.isFinished()) {
|
if (!mEdgeGlowBottom.isFinished()) {
|
||||||
mEdgeGlowBottom.onRelease();
|
mEdgeGlowBottom.onRelease();
|
||||||
}
|
}
|
||||||
invalidate(0, 0, getWidth(),
|
invalidateTopGlow();
|
||||||
mEdgeGlowTop.getMaxHeight() + getPaddingTop());
|
|
||||||
} else if (incrementalDeltaY < 0) {
|
} else if (incrementalDeltaY < 0) {
|
||||||
mEdgeGlowBottom.onPull((float) overscroll / getHeight(),
|
mEdgeGlowBottom.onPull((float) overscroll / getHeight(),
|
||||||
1.f - (float) x / getWidth());
|
1.f - (float) x / getWidth());
|
||||||
if (!mEdgeGlowTop.isFinished()) {
|
if (!mEdgeGlowTop.isFinished()) {
|
||||||
mEdgeGlowTop.onRelease();
|
mEdgeGlowTop.onRelease();
|
||||||
}
|
}
|
||||||
invalidate(0, getHeight() - getPaddingBottom() -
|
invalidateBottomGlow();
|
||||||
mEdgeGlowBottom.getMaxHeight(), getWidth(),
|
|
||||||
getHeight());
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -3539,17 +3533,14 @@ public abstract class AbsListView extends AdapterView<ListAdapter> implements Te
|
|||||||
if (!mEdgeGlowBottom.isFinished()) {
|
if (!mEdgeGlowBottom.isFinished()) {
|
||||||
mEdgeGlowBottom.onRelease();
|
mEdgeGlowBottom.onRelease();
|
||||||
}
|
}
|
||||||
invalidate(0, 0, getWidth(),
|
invalidateTopGlow();
|
||||||
mEdgeGlowTop.getMaxHeight() + getPaddingTop());
|
|
||||||
} else if (rawDeltaY < 0) {
|
} else if (rawDeltaY < 0) {
|
||||||
mEdgeGlowBottom.onPull((float) overScrollDistance / getHeight(),
|
mEdgeGlowBottom.onPull((float) overScrollDistance / getHeight(),
|
||||||
1.f - (float) x / getWidth());
|
1.f - (float) x / getWidth());
|
||||||
if (!mEdgeGlowTop.isFinished()) {
|
if (!mEdgeGlowTop.isFinished()) {
|
||||||
mEdgeGlowTop.onRelease();
|
mEdgeGlowTop.onRelease();
|
||||||
}
|
}
|
||||||
invalidate(0, getHeight() - getPaddingBottom() -
|
invalidateBottomGlow();
|
||||||
mEdgeGlowBottom.getMaxHeight(), getWidth(),
|
|
||||||
getHeight());
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -3581,6 +3572,28 @@ public abstract class AbsListView extends AdapterView<ListAdapter> implements Te
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void invalidateTopGlow() {
|
||||||
|
if (mEdgeGlowTop == null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
final boolean clipToPadding = getClipToPadding();
|
||||||
|
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 (mEdgeGlowBottom == null) {
|
||||||
|
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
|
||||||
public void onTouchModeChanged(boolean isInTouchMode) {
|
public void onTouchModeChanged(boolean isInTouchMode) {
|
||||||
if (isInTouchMode) {
|
if (isInTouchMode) {
|
||||||
@@ -4142,47 +4155,53 @@ public abstract class AbsListView extends AdapterView<ListAdapter> implements Te
|
|||||||
super.draw(canvas);
|
super.draw(canvas);
|
||||||
if (mEdgeGlowTop != null) {
|
if (mEdgeGlowTop != null) {
|
||||||
final int scrollY = mScrollY;
|
final int scrollY = mScrollY;
|
||||||
|
final boolean clipToPadding = getClipToPadding();
|
||||||
|
final int width;
|
||||||
|
final int height;
|
||||||
|
final int translateX;
|
||||||
|
final int translateY;
|
||||||
|
|
||||||
|
if (clipToPadding) {
|
||||||
|
width = getWidth() - mPaddingLeft - mPaddingRight;
|
||||||
|
height = getHeight() - mPaddingTop - mPaddingBottom;
|
||||||
|
translateX = mPaddingLeft;
|
||||||
|
translateY = mPaddingTop;
|
||||||
|
} else {
|
||||||
|
width = getWidth();
|
||||||
|
height = getHeight();
|
||||||
|
translateX = 0;
|
||||||
|
translateY = 0;
|
||||||
|
}
|
||||||
if (!mEdgeGlowTop.isFinished()) {
|
if (!mEdgeGlowTop.isFinished()) {
|
||||||
final int restoreCount = canvas.save();
|
final int restoreCount = canvas.save();
|
||||||
final int width = getWidth();
|
canvas.clipRect(translateX, translateY,
|
||||||
|
translateX + width ,translateY + mEdgeGlowTop.getMaxHeight());
|
||||||
int edgeY = Math.min(0, scrollY + mFirstPositionDistanceGuess);
|
final int edgeY = Math.min(0, scrollY + mFirstPositionDistanceGuess) + translateY;
|
||||||
canvas.translate(0, edgeY);
|
canvas.translate(translateX, edgeY);
|
||||||
mEdgeGlowTop.setSize(width, getHeight());
|
mEdgeGlowTop.setSize(width, height);
|
||||||
if (mEdgeGlowTop.draw(canvas)) {
|
if (mEdgeGlowTop.draw(canvas)) {
|
||||||
invalidate(0, 0, getWidth(),
|
invalidateTopGlow();
|
||||||
mEdgeGlowTop.getMaxHeight() + getPaddingTop());
|
|
||||||
}
|
}
|
||||||
canvas.restoreToCount(restoreCount);
|
canvas.restoreToCount(restoreCount);
|
||||||
}
|
}
|
||||||
if (!mEdgeGlowBottom.isFinished()) {
|
if (!mEdgeGlowBottom.isFinished()) {
|
||||||
final int restoreCount = canvas.save();
|
final int restoreCount = canvas.save();
|
||||||
final int width = getWidth();
|
canvas.clipRect(translateX, translateY + height - mEdgeGlowBottom.getMaxHeight(),
|
||||||
final int height = getHeight();
|
translateX + width, translateY + height);
|
||||||
|
final int edgeX = -width + translateX;
|
||||||
int edgeX = -width;
|
final int edgeY = Math.max(getHeight(), scrollY + mLastPositionDistanceGuess)
|
||||||
int edgeY = Math.max(height, scrollY + mLastPositionDistanceGuess);
|
- (clipToPadding ? mPaddingBottom : 0);
|
||||||
canvas.translate(edgeX, edgeY);
|
canvas.translate(edgeX, edgeY);
|
||||||
canvas.rotate(180, width, 0);
|
canvas.rotate(180, width, 0);
|
||||||
mEdgeGlowBottom.setSize(width, height);
|
mEdgeGlowBottom.setSize(width, height);
|
||||||
if (mEdgeGlowBottom.draw(canvas)) {
|
if (mEdgeGlowBottom.draw(canvas)) {
|
||||||
invalidate(0, getHeight() - getPaddingBottom() -
|
invalidateBottomGlow();
|
||||||
mEdgeGlowBottom.getMaxHeight(), getWidth(),
|
|
||||||
getHeight());
|
|
||||||
}
|
}
|
||||||
canvas.restoreToCount(restoreCount);
|
canvas.restoreToCount(restoreCount);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @hide
|
|
||||||
*/
|
|
||||||
public void setOverScrollEffectPadding(int leftPadding, int rightPadding) {
|
|
||||||
mGlowPaddingLeft = leftPadding;
|
|
||||||
mGlowPaddingRight = rightPadding;
|
|
||||||
}
|
|
||||||
|
|
||||||
private void initOrResetVelocityTracker() {
|
private void initOrResetVelocityTracker() {
|
||||||
if (mVelocityTracker == null) {
|
if (mVelocityTracker == null) {
|
||||||
mVelocityTracker = VelocityTracker.obtain();
|
mVelocityTracker = VelocityTracker.obtain();
|
||||||
|
|||||||
Reference in New Issue
Block a user