Merge "Fix TYPE_VIEW_SCROLLED event in AsListView and ListView"
This commit is contained in:
@@ -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() {
|
||||
|
||||
@@ -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) {
|
||||
|
||||
Reference in New Issue
Block a user