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

Commit 9407e393 authored by yingleiw's avatar yingleiw
Browse files

Fix TYPE_VIEW_SCROLLED event in AsListView and ListView

We should always send TYPE_VIEW_SCROLLED event when scroll. This applies
to ACTION_SHOW_ON_SCREEN. And we also need the scroll event when the
first visible item and last visibile item don't change.

Fix: 147907655, 147282475

Test: tested b/147282475 is fixed (this bug is not related to
ACTION_SHOW_ON_SCREEN, it is the scroll forward action).

Change-Id: I2069dc3ee692042ff87867db9837e85ac1d8dd26
parent 68fe9164
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) {