Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 0a1b818b authored by Gilles Debunne's avatar Gilles Debunne
Browse files

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
parent 6c2193a7
Loading
Loading
Loading
Loading
+25 −25
Original line number Diff line number Diff line
@@ -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,8 +3250,9 @@ public abstract class AbsListView extends AdapterView<ListAdapter> implements Te
    }

    @Override
    protected void onOverScrolled(int scrollX, int scrollY,
            boolean clampedX, boolean clampedY) {
    protected void onOverScrolled(int scrollX, int scrollY, boolean clampedX, boolean clampedY) {
        if (mScrollY != scrollY) {
            onScrollChanged(mScrollX, scrollY, mScrollX, mScrollY);
            mScrollY = scrollY;
            invalidateParentIfNeeded();

@@ -3260,6 +3264,7 @@ public abstract class AbsListView extends AdapterView<ListAdapter> implements Te
            }
            awakenScrollBars();
        }
    }

    @Override
    public boolean onGenericMotionEvent(MotionEvent event) {
@@ -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;
        }