am e7c02ef4: Merge "Fix bug 2973252 - Make overscroll glow respect ifContentScrolls" into gingerbread
Merge commit 'e7c02ef40a10c599b13684a6f99a91eabd0f258f' into gingerbread-plus-aosp * commit 'e7c02ef40a10c599b13684a6f99a91eabd0f258f': Fix bug 2973252 - Make overscroll glow respect ifContentScrolls
This commit is contained in:
@@ -658,6 +658,18 @@ public abstract class AbsListView extends AdapterView<ListAdapter> implements Te
|
|||||||
super.setOverscrollMode(mode);
|
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
|
* 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
|
* 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.
|
// Don't allow overfling if we're at the edge.
|
||||||
mVelocityTracker.clear();
|
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) {
|
if (rawDeltaY > 0) {
|
||||||
mEdgeGlowTop.onPull((float) overscroll / getHeight());
|
mEdgeGlowTop.onPull((float) overscroll / getHeight());
|
||||||
} else if (rawDeltaY < 0) {
|
} else if (rawDeltaY < 0) {
|
||||||
@@ -2275,7 +2291,10 @@ public abstract class AbsListView extends AdapterView<ListAdapter> implements Te
|
|||||||
} else {
|
} else {
|
||||||
overscrollBy(0, -incrementalDeltaY, 0, mScrollY, 0, 0,
|
overscrollBy(0, -incrementalDeltaY, 0, mScrollY, 0, 0,
|
||||||
0, mOverscrollDistance, true);
|
0, mOverscrollDistance, true);
|
||||||
if (mEdgeGlowTop != null) {
|
final int overscrollMode = getOverscrollMode();
|
||||||
|
if (overscrollMode == OVERSCROLL_ALWAYS ||
|
||||||
|
(overscrollMode == OVERSCROLL_IF_CONTENT_SCROLLS &&
|
||||||
|
!contentFits())) {
|
||||||
if (rawDeltaY > 0) {
|
if (rawDeltaY > 0) {
|
||||||
mEdgeGlowTop.onPull((float) -incrementalDeltaY / getHeight());
|
mEdgeGlowTop.onPull((float) -incrementalDeltaY / getHeight());
|
||||||
} else if (rawDeltaY < 0) {
|
} else if (rawDeltaY < 0) {
|
||||||
@@ -2757,8 +2776,10 @@ public abstract class AbsListView extends AdapterView<ListAdapter> implements Te
|
|||||||
|
|
||||||
void edgeReached(int delta) {
|
void edgeReached(int delta) {
|
||||||
mScroller.notifyVerticalEdgeReached(mScrollY, 0, mOverflingDistance);
|
mScroller.notifyVerticalEdgeReached(mScrollY, 0, mOverflingDistance);
|
||||||
mTouchMode = TOUCH_MODE_OVERFLING;
|
final int overscrollMode = getOverscrollMode();
|
||||||
if (mEdgeGlowTop != null) {
|
if (overscrollMode == OVERSCROLL_ALWAYS ||
|
||||||
|
(overscrollMode == OVERSCROLL_IF_CONTENT_SCROLLS && !contentFits())) {
|
||||||
|
mTouchMode = TOUCH_MODE_OVERFLING;
|
||||||
final int vel = (int) mScroller.getCurrVelocity();
|
final int vel = (int) mScroller.getCurrVelocity();
|
||||||
if (delta > 0) {
|
if (delta > 0) {
|
||||||
mEdgeGlowTop.onAbsorb(vel);
|
mEdgeGlowTop.onAbsorb(vel);
|
||||||
|
|||||||
@@ -538,11 +538,15 @@ public class HorizontalScrollView extends FrameLayout {
|
|||||||
}
|
}
|
||||||
onScrollChanged(mScrollX, mScrollY, oldX, oldY);
|
onScrollChanged(mScrollX, mScrollY, oldX, oldY);
|
||||||
|
|
||||||
final int pulledToX = oldX + deltaX;
|
final int overscrollMode = getOverscrollMode();
|
||||||
if (pulledToX < 0) {
|
if (overscrollMode == OVERSCROLL_ALWAYS ||
|
||||||
mEdgeGlowLeft.onPull((float) deltaX / getWidth());
|
(overscrollMode == OVERSCROLL_IF_CONTENT_SCROLLS && range > 0)) {
|
||||||
} else if (pulledToX > range) {
|
final int pulledToX = oldX + deltaX;
|
||||||
mEdgeGlowRight.onPull((float) deltaX / getWidth());
|
if (pulledToX < 0) {
|
||||||
|
mEdgeGlowLeft.onPull((float) deltaX / getWidth());
|
||||||
|
} else if (pulledToX > range) {
|
||||||
|
mEdgeGlowRight.onPull((float) deltaX / getWidth());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
@@ -1091,10 +1095,14 @@ public class HorizontalScrollView extends FrameLayout {
|
|||||||
onScrollChanged(mScrollX, mScrollY, oldX, oldY);
|
onScrollChanged(mScrollX, mScrollY, oldX, oldY);
|
||||||
|
|
||||||
final int range = getScrollRange();
|
final int range = getScrollRange();
|
||||||
if (x < 0 && oldX >= 0) {
|
final int overscrollMode = getOverscrollMode();
|
||||||
mEdgeGlowLeft.onAbsorb((int) mScroller.getCurrVelocity());
|
if (overscrollMode == OVERSCROLL_ALWAYS ||
|
||||||
} else if (x > range && oldX <= range) {
|
(overscrollMode == OVERSCROLL_IF_CONTENT_SCROLLS && range > 0)) {
|
||||||
mEdgeGlowRight.onAbsorb((int) mScroller.getCurrVelocity());
|
if (x < 0 && oldX >= 0) {
|
||||||
|
mEdgeGlowLeft.onAbsorb((int) mScroller.getCurrVelocity());
|
||||||
|
} else if (x > range && oldX <= range) {
|
||||||
|
mEdgeGlowRight.onAbsorb((int) mScroller.getCurrVelocity());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
awakenScrollBars();
|
awakenScrollBars();
|
||||||
|
|||||||
@@ -533,11 +533,15 @@ public class ScrollView extends FrameLayout {
|
|||||||
}
|
}
|
||||||
onScrollChanged(mScrollX, mScrollY, oldX, oldY);
|
onScrollChanged(mScrollX, mScrollY, oldX, oldY);
|
||||||
|
|
||||||
final int pulledToY = oldY + deltaY;
|
final int overscrollMode = getOverscrollMode();
|
||||||
if (pulledToY < 0) {
|
if (overscrollMode == OVERSCROLL_ALWAYS ||
|
||||||
mEdgeGlowTop.onPull((float) deltaY / getHeight());
|
(overscrollMode == OVERSCROLL_IF_CONTENT_SCROLLS && range > 0)) {
|
||||||
} else if (pulledToY > range) {
|
final int pulledToY = oldY + deltaY;
|
||||||
mEdgeGlowBottom.onPull((float) deltaY / getHeight());
|
if (pulledToY < 0) {
|
||||||
|
mEdgeGlowTop.onPull((float) deltaY / getHeight());
|
||||||
|
} else if (pulledToY > range) {
|
||||||
|
mEdgeGlowBottom.onPull((float) deltaY / getHeight());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
@@ -1090,10 +1094,14 @@ public class ScrollView extends FrameLayout {
|
|||||||
onScrollChanged(mScrollX, mScrollY, oldX, oldY);
|
onScrollChanged(mScrollX, mScrollY, oldX, oldY);
|
||||||
|
|
||||||
final int range = getScrollRange();
|
final int range = getScrollRange();
|
||||||
if (y < 0 && oldY >= 0) {
|
final int overscrollMode = getOverscrollMode();
|
||||||
mEdgeGlowTop.onAbsorb((int) mScroller.getCurrVelocity());
|
if (overscrollMode == OVERSCROLL_ALWAYS ||
|
||||||
} else if (y > range && oldY <= range) {
|
(overscrollMode == OVERSCROLL_IF_CONTENT_SCROLLS && range > 0)) {
|
||||||
mEdgeGlowBottom.onAbsorb((int) mScroller.getCurrVelocity());
|
if (y < 0 && oldY >= 0) {
|
||||||
|
mEdgeGlowTop.onAbsorb((int) mScroller.getCurrVelocity());
|
||||||
|
} else if (y > range && oldY <= range) {
|
||||||
|
mEdgeGlowBottom.onAbsorb((int) mScroller.getCurrVelocity());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
awakenScrollBars();
|
awakenScrollBars();
|
||||||
|
|||||||
Reference in New Issue
Block a user