Merge "Fix bug 2973252 - Make overscroll glow respect ifContentScrolls" into gingerbread
This commit is contained in:
@@ -658,6 +658,18 @@ public abstract class AbsListView extends AdapterView<ListAdapter> implements Te
|
||||
super.setOverscrollMode(mode);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return true if all list content currently fits within the view boundaries
|
||||
*/
|
||||
private boolean contentFits() {
|
||||
final int childCount = getChildCount();
|
||||
if (childCount != mItemCount) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return getChildAt(0).getTop() >= 0 && getChildAt(childCount - 1).getBottom() <= mBottom;
|
||||
}
|
||||
|
||||
/**
|
||||
* Enables fast scrolling by letting the user quickly scroll through lists by
|
||||
* dragging the fast scroll thumb. The adapter attached to the list may want
|
||||
@@ -2221,8 +2233,12 @@ public abstract class AbsListView extends AdapterView<ListAdapter> implements Te
|
||||
// Don't allow overfling if we're at the edge.
|
||||
mVelocityTracker.clear();
|
||||
}
|
||||
mTouchMode = TOUCH_MODE_OVERSCROLL;
|
||||
if (mEdgeGlowTop != null) {
|
||||
|
||||
final int overscrollMode = getOverscrollMode();
|
||||
if (overscrollMode == OVERSCROLL_ALWAYS ||
|
||||
(overscrollMode == OVERSCROLL_IF_CONTENT_SCROLLS &&
|
||||
!contentFits())) {
|
||||
mTouchMode = TOUCH_MODE_OVERSCROLL;
|
||||
if (rawDeltaY > 0) {
|
||||
mEdgeGlowTop.onPull((float) overscroll / getHeight());
|
||||
} else if (rawDeltaY < 0) {
|
||||
@@ -2275,7 +2291,10 @@ public abstract class AbsListView extends AdapterView<ListAdapter> implements Te
|
||||
} else {
|
||||
overscrollBy(0, -incrementalDeltaY, 0, mScrollY, 0, 0,
|
||||
0, mOverscrollDistance, true);
|
||||
if (mEdgeGlowTop != null) {
|
||||
final int overscrollMode = getOverscrollMode();
|
||||
if (overscrollMode == OVERSCROLL_ALWAYS ||
|
||||
(overscrollMode == OVERSCROLL_IF_CONTENT_SCROLLS &&
|
||||
!contentFits())) {
|
||||
if (rawDeltaY > 0) {
|
||||
mEdgeGlowTop.onPull((float) -incrementalDeltaY / getHeight());
|
||||
} else if (rawDeltaY < 0) {
|
||||
@@ -2757,8 +2776,10 @@ public abstract class AbsListView extends AdapterView<ListAdapter> implements Te
|
||||
|
||||
void edgeReached(int delta) {
|
||||
mScroller.notifyVerticalEdgeReached(mScrollY, 0, mOverflingDistance);
|
||||
mTouchMode = TOUCH_MODE_OVERFLING;
|
||||
if (mEdgeGlowTop != null) {
|
||||
final int overscrollMode = getOverscrollMode();
|
||||
if (overscrollMode == OVERSCROLL_ALWAYS ||
|
||||
(overscrollMode == OVERSCROLL_IF_CONTENT_SCROLLS && !contentFits())) {
|
||||
mTouchMode = TOUCH_MODE_OVERFLING;
|
||||
final int vel = (int) mScroller.getCurrVelocity();
|
||||
if (delta > 0) {
|
||||
mEdgeGlowTop.onAbsorb(vel);
|
||||
|
||||
@@ -538,11 +538,15 @@ public class HorizontalScrollView extends FrameLayout {
|
||||
}
|
||||
onScrollChanged(mScrollX, mScrollY, oldX, oldY);
|
||||
|
||||
final int pulledToX = oldX + deltaX;
|
||||
if (pulledToX < 0) {
|
||||
mEdgeGlowLeft.onPull((float) deltaX / getWidth());
|
||||
} else if (pulledToX > range) {
|
||||
mEdgeGlowRight.onPull((float) deltaX / getWidth());
|
||||
final int overscrollMode = getOverscrollMode();
|
||||
if (overscrollMode == OVERSCROLL_ALWAYS ||
|
||||
(overscrollMode == OVERSCROLL_IF_CONTENT_SCROLLS && range > 0)) {
|
||||
final int pulledToX = oldX + deltaX;
|
||||
if (pulledToX < 0) {
|
||||
mEdgeGlowLeft.onPull((float) deltaX / getWidth());
|
||||
} else if (pulledToX > range) {
|
||||
mEdgeGlowRight.onPull((float) deltaX / getWidth());
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
@@ -1091,10 +1095,14 @@ public class HorizontalScrollView extends FrameLayout {
|
||||
onScrollChanged(mScrollX, mScrollY, oldX, oldY);
|
||||
|
||||
final int range = getScrollRange();
|
||||
if (x < 0 && oldX >= 0) {
|
||||
mEdgeGlowLeft.onAbsorb((int) mScroller.getCurrVelocity());
|
||||
} else if (x > range && oldX <= range) {
|
||||
mEdgeGlowRight.onAbsorb((int) mScroller.getCurrVelocity());
|
||||
final int overscrollMode = getOverscrollMode();
|
||||
if (overscrollMode == OVERSCROLL_ALWAYS ||
|
||||
(overscrollMode == OVERSCROLL_IF_CONTENT_SCROLLS && range > 0)) {
|
||||
if (x < 0 && oldX >= 0) {
|
||||
mEdgeGlowLeft.onAbsorb((int) mScroller.getCurrVelocity());
|
||||
} else if (x > range && oldX <= range) {
|
||||
mEdgeGlowRight.onAbsorb((int) mScroller.getCurrVelocity());
|
||||
}
|
||||
}
|
||||
}
|
||||
awakenScrollBars();
|
||||
|
||||
@@ -533,11 +533,15 @@ public class ScrollView extends FrameLayout {
|
||||
}
|
||||
onScrollChanged(mScrollX, mScrollY, oldX, oldY);
|
||||
|
||||
final int pulledToY = oldY + deltaY;
|
||||
if (pulledToY < 0) {
|
||||
mEdgeGlowTop.onPull((float) deltaY / getHeight());
|
||||
} else if (pulledToY > range) {
|
||||
mEdgeGlowBottom.onPull((float) deltaY / getHeight());
|
||||
final int overscrollMode = getOverscrollMode();
|
||||
if (overscrollMode == OVERSCROLL_ALWAYS ||
|
||||
(overscrollMode == OVERSCROLL_IF_CONTENT_SCROLLS && range > 0)) {
|
||||
final int pulledToY = oldY + deltaY;
|
||||
if (pulledToY < 0) {
|
||||
mEdgeGlowTop.onPull((float) deltaY / getHeight());
|
||||
} else if (pulledToY > range) {
|
||||
mEdgeGlowBottom.onPull((float) deltaY / getHeight());
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
@@ -1090,10 +1094,14 @@ public class ScrollView extends FrameLayout {
|
||||
onScrollChanged(mScrollX, mScrollY, oldX, oldY);
|
||||
|
||||
final int range = getScrollRange();
|
||||
if (y < 0 && oldY >= 0) {
|
||||
mEdgeGlowTop.onAbsorb((int) mScroller.getCurrVelocity());
|
||||
} else if (y > range && oldY <= range) {
|
||||
mEdgeGlowBottom.onAbsorb((int) mScroller.getCurrVelocity());
|
||||
final int overscrollMode = getOverscrollMode();
|
||||
if (overscrollMode == OVERSCROLL_ALWAYS ||
|
||||
(overscrollMode == OVERSCROLL_IF_CONTENT_SCROLLS && range > 0)) {
|
||||
if (y < 0 && oldY >= 0) {
|
||||
mEdgeGlowTop.onAbsorb((int) mScroller.getCurrVelocity());
|
||||
} else if (y > range && oldY <= range) {
|
||||
mEdgeGlowBottom.onAbsorb((int) mScroller.getCurrVelocity());
|
||||
}
|
||||
}
|
||||
}
|
||||
awakenScrollBars();
|
||||
|
||||
Reference in New Issue
Block a user