OSDN Git Service

Don't auto scroll empty lists
authorAlan Viverette <alanv@google.com>
Mon, 7 Apr 2014 16:30:13 +0000 (09:30 -0700)
committerAlan Viverette <alanv@google.com>
Mon, 7 Apr 2014 16:30:13 +0000 (09:30 -0700)
BUG: 12930741
Change-Id: I22bcebace0d5e0d519d38b34d6312ffff5b62f9b

core/java/com/android/internal/widget/AutoScrollHelper.java

index 7a294aa..0d468ca 100644 (file)
@@ -892,6 +892,10 @@ public abstract class AutoScrollHelper implements View.OnTouchListener {
         public boolean canTargetScrollVertically(int direction) {
             final AbsListView target = mTarget;
             final int itemCount = target.getCount();
+            if (itemCount == 0) {
+                return false;
+            }
+
             final int childCount = target.getChildCount();
             final int firstPosition = target.getFirstVisiblePosition();
             final int lastPosition = firstPosition + childCount;