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

Commit 04c84989 authored by Yinglei Wang's avatar Yinglei Wang Committed by Android (Google) Code Review
Browse files

Merge "Fix TYPE_VIEW_SCROLLED event in AsListView and ListView"

parents 695cfc20 9407e393
Loading
Loading
Loading
Loading
+4 −22
Original line number Diff line number Diff line
@@ -756,9 +756,6 @@ public abstract class AbsListView extends AdapterView<ListAdapter> implements Te
     */
    private ListItemAccessibilityDelegate mAccessibilityDelegate;

    private int mLastAccessibilityScrollEventFromIndex;
    private int mLastAccessibilityScrollEventToIndex;

    /**
     * Track the item count from the last time we handled a data change.
     */
@@ -1520,25 +1517,10 @@ public abstract class AbsListView extends AdapterView<ListAdapter> implements Te
        onScrollChanged(0, 0, 0, 0); // dummy values, View's implementation does not use these.
    }

    /** @hide */
    @Override
    public void sendAccessibilityEventUnchecked(AccessibilityEvent event) {
        // Since this class calls onScrollChanged even if the mFirstPosition and the
        // child count have not changed we will avoid sending duplicate accessibility
        // events.
        if (event.getEventType() == AccessibilityEvent.TYPE_VIEW_SCROLLED) {
            final int firstVisiblePosition = getFirstVisiblePosition();
            final int lastVisiblePosition = getLastVisiblePosition();
            if (mLastAccessibilityScrollEventFromIndex == firstVisiblePosition
                    && mLastAccessibilityScrollEventToIndex == lastVisiblePosition) {
                return;
            } else {
                mLastAccessibilityScrollEventFromIndex = firstVisiblePosition;
                mLastAccessibilityScrollEventToIndex = lastVisiblePosition;
            }
        }
        super.sendAccessibilityEventUnchecked(event);
    }
    /**
     * A TYPE_VIEW_SCROLLED event should be sent whenever a scroll happens, even if the
     * mFirstPosition and the child count have not changed.
     */

    @Override
    public CharSequence getAccessibilityClassName() {
+4 −0
Original line number Diff line number Diff line
@@ -3255,6 +3255,9 @@ public class ListView extends AbsListView {
     */
    @UnsupportedAppUsage
    private void scrollListItemsBy(int amount) {
        int oldX = mScrollX;
        int oldY = mScrollY;

        offsetChildrenTopAndBottom(amount);

        final int listBottom = getHeight() - mListPadding.bottom;
@@ -3327,6 +3330,7 @@ public class ListView extends AbsListView {
        recycleBin.fullyDetachScrapViews();
        removeUnusedFixedViews(mHeaderViewInfos);
        removeUnusedFixedViews(mFooterViewInfos);
        onScrollChanged(mScrollX, mScrollY, oldX, oldY);
    }

    private View addViewAbove(View theView, int position) {