Only look for nearest child View in ViewGroup
NearestTouchDelegate may still be assigned to non-ViewGroup views, but
we won't attempt to find a target child View until the touch moves into
a ViewGroup.
Bug: 25813455
Change-Id: I570f88fee63623110e3463e8d4579cca8113fd5e
diff --git a/core/java/android/widget/TimePickerClockDelegate.java b/core/java/android/widget/TimePickerClockDelegate.java
index a24fb40..1d6e52c 100644
--- a/core/java/android/widget/TimePickerClockDelegate.java
+++ b/core/java/android/widget/TimePickerClockDelegate.java
@@ -880,8 +880,12 @@
public boolean onTouch(View view, MotionEvent motionEvent) {
final int actionMasked = motionEvent.getActionMasked();
if (actionMasked == MotionEvent.ACTION_DOWN) {
- mInitialTouchTarget = findNearestChild((ViewGroup) view,
- (int) motionEvent.getX(), (int) motionEvent.getY());
+ if (view instanceof ViewGroup) {
+ mInitialTouchTarget = findNearestChild((ViewGroup) view,
+ (int) motionEvent.getX(), (int) motionEvent.getY());
+ } else {
+ mInitialTouchTarget = null;
+ }
}
final View child = mInitialTouchTarget;