Fix bug 3192412 - ListView doesn't reportScrollStateChange properly
for programmatic scrolls
Allow for onScrollStateChanged implementations that end up changing
scroll state again.
Change-Id: I53105f5be708bacc0d3ec8e76ba1cc22f4131467
diff --git a/core/java/android/widget/AbsListView.java b/core/java/android/widget/AbsListView.java
index ab5ff3d..30b1e5d 100644
--- a/core/java/android/widget/AbsListView.java
+++ b/core/java/android/widget/AbsListView.java
@@ -2893,8 +2893,8 @@
void reportScrollStateChange(int newState) {
if (newState != mLastScrollState) {
if (mOnScrollListener != null) {
- mOnScrollListener.onScrollStateChanged(this, newState);
mLastScrollState = newState;
+ mOnScrollListener.onScrollStateChanged(this, newState);
}
}
}
@@ -3431,12 +3431,13 @@
public void smoothScrollBy(int distance, int duration) {
if (mFlingRunnable == null) {
mFlingRunnable = new FlingRunnable();
- } else {
- mFlingRunnable.endFling();
}
// No sense starting to scroll if we're not going anywhere
if (distance != 0) {
+ reportScrollStateChange(OnScrollListener.SCROLL_STATE_FLING);
mFlingRunnable.startScroll(distance, duration);
+ } else {
+ mFlingRunnable.endFling();
}
}