summaryrefslogtreecommitdiffstats
path: root/core/java/android/widget
diff options
context:
space:
mode:
authorJeff Brown <jeffbrown@google.com>2011-01-18 18:22:48 -0800
committerJeff Brown <jeffbrown@google.com>2011-01-19 11:20:46 -0800
commit39bc6197baa7482dd070878a63992e8212965a4d (patch)
treed38f57adc731ff7a75a097390e4eb5d1d3eaa1ae /core/java/android/widget
parentb735aa0b6fabb72097191923d8787b43fa52531e (diff)
downloadframeworks_base-39bc6197baa7482dd070878a63992e8212965a4d.zip
frameworks_base-39bc6197baa7482dd070878a63992e8212965a4d.tar.gz
frameworks_base-39bc6197baa7482dd070878a63992e8212965a4d.tar.bz2
Never drag scroll views with no children. (DO NOT MERGE)
Fixes a regression from Froyo. Previously, when a scroll view had no children, its onTouchEvent would return because the scroll view would only start dragging if the user touched one of its children. In Gingerbread, the user can drag from anywhere within the scroll view, not just by touching a child. However, it makes no sense to drag a scroll view that has no children so an empty scroll view should just ignore touches like any other empty view group would. This change fixes applications that for some reason or other happen to have empty scroll views in strange places. Bug: 3246230 Change-Id: I76c6136d3cd74968983033014d60deec1718ce30
Diffstat (limited to 'core/java/android/widget')
-rw-r--r--core/java/android/widget/HorizontalScrollView.java8
-rw-r--r--core/java/android/widget/ScrollView.java10
2 files changed, 11 insertions, 7 deletions
diff --git a/core/java/android/widget/HorizontalScrollView.java b/core/java/android/widget/HorizontalScrollView.java
index fee3455..db54a0d 100644
--- a/core/java/android/widget/HorizontalScrollView.java
+++ b/core/java/android/widget/HorizontalScrollView.java
@@ -502,8 +502,10 @@ public class HorizontalScrollView extends FrameLayout {
switch (action & MotionEvent.ACTION_MASK) {
case MotionEvent.ACTION_DOWN: {
- final float x = ev.getX();
- mIsBeingDragged = true;
+ mIsBeingDragged = getChildCount() != 0;
+ if (!mIsBeingDragged) {
+ return false;
+ }
/*
* If being flinged and user touches, stop the fling. isFinished
@@ -514,7 +516,7 @@ public class HorizontalScrollView extends FrameLayout {
}
// Remember where the motion event started
- mLastMotionX = x;
+ mLastMotionX = ev.getX();
mActivePointerId = ev.getPointerId(0);
break;
}
diff --git a/core/java/android/widget/ScrollView.java b/core/java/android/widget/ScrollView.java
index 2ad67ba..de38d05 100644
--- a/core/java/android/widget/ScrollView.java
+++ b/core/java/android/widget/ScrollView.java
@@ -497,9 +497,11 @@ public class ScrollView extends FrameLayout {
switch (action & MotionEvent.ACTION_MASK) {
case MotionEvent.ACTION_DOWN: {
- final float y = ev.getY();
- mIsBeingDragged = true;
-
+ mIsBeingDragged = getChildCount() != 0;
+ if (!mIsBeingDragged) {
+ return false;
+ }
+
/*
* If being flinged and user touches, stop the fling. isFinished
* will be false if being flinged.
@@ -509,7 +511,7 @@ public class ScrollView extends FrameLayout {
}
// Remember where the motion event started
- mLastMotionY = y;
+ mLastMotionY = ev.getY();
mActivePointerId = ev.getPointerId(0);
break;
}