summaryrefslogtreecommitdiffstats
path: root/core
diff options
context:
space:
mode:
authorGilles Debunne <debunne@google.com>2011-02-28 16:01:09 -0800
committerGilles Debunne <debunne@google.com>2011-03-01 10:58:22 -0800
commit0a1b818b8c45c8b100eeabb5c59bb4d85cf90868 (patch)
treed5d27a38951e38faabdeac6626b95d9f846c6626 /core
parent6c2193a7e26c0794f45dfb60d2a0cf6ae776f390 (diff)
downloadframeworks_base-0a1b818b8c45c8b100eeabb5c59bb4d85cf90868.zip
frameworks_base-0a1b818b8c45c8b100eeabb5c59bb4d85cf90868.tar.gz
frameworks_base-0a1b818b8c45c8b100eeabb5c59bb4d85cf90868.tar.bz2
AbsListView notifies scroll events to the ViewTreeObserver.
ViewTreeObserver OnScrollChangedListener will then get notified. The scroll values are not specified, since they are passed to the base View.onScrollChanged method that simply sets the flags. No need to throw these from a Runnable (in case this happens during a relayout) since the listeners will be notified later from ViewRoot.draw(). Calling View.onScrollChanged in invokeOnItemScrollListener for normal scroll and in onOverScrolled to handle mScroller animation. Change-Id: Ib41434e5cd82e5a45ca6653db576746e89ef072d
Diffstat (limited to 'core')
-rw-r--r--core/java/android/widget/AbsListView.java50
1 files changed, 25 insertions, 25 deletions
diff --git a/core/java/android/widget/AbsListView.java b/core/java/android/widget/AbsListView.java
index 1d05d0b..7b0739b 100644
--- a/core/java/android/widget/AbsListView.java
+++ b/core/java/android/widget/AbsListView.java
@@ -1251,6 +1251,7 @@ public abstract class AbsListView extends AdapterView<ListAdapter> implements Te
if (mOnScrollListener != null) {
mOnScrollListener.onScroll(this, mFirstPosition, getChildCount(), mItemCount);
}
+ onScrollChanged(0, 0, 0, 0); // dummy values, View's implementation does not use these.
}
/**
@@ -2793,8 +2794,9 @@ public abstract class AbsListView extends AdapterView<ListAdapter> implements Te
if (!mDataChanged) {
if ((mTouchMode != TOUCH_MODE_FLING) && (motionPosition >= 0)
&& (getAdapter().isEnabled(motionPosition))) {
- // User clicked on an actual view (and was not stopping a fling). It might be a
- // click or a scroll. Assume it is a click until proven otherwise
+ // User clicked on an actual view (and was not stopping a fling).
+ // It might be a click or a scroll. Assume it is a click until
+ // proven otherwise
mTouchMode = TOUCH_MODE_DOWN;
// FIXME Debounce
if (mPendingCheckForTap == null) {
@@ -2803,9 +2805,10 @@ public abstract class AbsListView extends AdapterView<ListAdapter> implements Te
postDelayed(mPendingCheckForTap, ViewConfiguration.getTapTimeout());
} else {
if (ev.getEdgeFlags() != 0 && motionPosition < 0) {
- // If we couldn't find a view to click on, but the down event was touching
- // the edge, we will bail out and try again. This allows the edge correcting
- // code in ViewRoot to try to find a nearby view to select
+ // If we couldn't find a view to click on, but the down event
+ // was touching the edge, we will bail out and try again.
+ // This allows the edge correcting code in ViewRoot to try to
+ // find a nearby view to select
return false;
}
@@ -3247,18 +3250,20 @@ public abstract class AbsListView extends AdapterView<ListAdapter> implements Te
}
@Override
- protected void onOverScrolled(int scrollX, int scrollY,
- boolean clampedX, boolean clampedY) {
- mScrollY = scrollY;
- invalidateParentIfNeeded();
-
- if (clampedY) {
- // Velocity is broken by hitting the limit; don't start a fling off of this.
- if (mVelocityTracker != null) {
- mVelocityTracker.clear();
+ protected void onOverScrolled(int scrollX, int scrollY, boolean clampedX, boolean clampedY) {
+ if (mScrollY != scrollY) {
+ onScrollChanged(mScrollX, scrollY, mScrollX, mScrollY);
+ mScrollY = scrollY;
+ invalidateParentIfNeeded();
+
+ if (clampedY) {
+ // Velocity is broken by hitting the limit; don't start a fling off of this.
+ if (mVelocityTracker != null) {
+ mVelocityTracker.clear();
+ }
}
+ awakenScrollBars();
}
- awakenScrollBars();
}
@Override
@@ -4279,17 +4284,12 @@ public abstract class AbsListView extends AdapterView<ListAdapter> implements Te
mLastPositionDistanceGuess += incrementalDeltaY;
}
- if (firstPosition == 0 && firstTop >= listPadding.top && incrementalDeltaY >= 0) {
- // Don't need to move views down if the top of the first position
- // is already visible
- return incrementalDeltaY != 0;
- }
+ final boolean cannotScrollDown = (firstPosition == 0 &&
+ firstTop >= listPadding.top && incrementalDeltaY >= 0);
+ final boolean cannotScrollUp = (firstPosition + childCount == mItemCount &&
+ lastBottom <= getHeight() - listPadding.bottom && incrementalDeltaY <= 0);
- if (firstPosition + childCount == mItemCount &&
- lastBottom <= getHeight() - listPadding.bottom &&
- incrementalDeltaY <= 0) {
- // Don't need to move views up if the bottom of the last position
- // is already visible
+ if (cannotScrollDown || cannotScrollUp) {
return incrementalDeltaY != 0;
}