From 418d0cf5c997491be8cfeb509e35c412dd31409d Mon Sep 17 00:00:00 2001 From: Yigit Boyar Date: Tue, 1 Mar 2016 16:09:58 -0800 Subject: [PATCH] Check if item is selectable before calling on click This CL fixes a bug in ListView where it might call onClick on an un-clickable if a new touch arrives before up timeout. We could actually consider making child position non-changable but that will change behavior. This seems safer approach. Bug: 27198796 Change-Id: I7b15d04efa19d1d760a294bd027f3da3aaa3a445 --- core/java/android/widget/AbsListView.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/core/java/android/widget/AbsListView.java b/core/java/android/widget/AbsListView.java index 496f7eee27f79..d2aef0ac362c4 100644 --- a/core/java/android/widget/AbsListView.java +++ b/core/java/android/widget/AbsListView.java @@ -3078,7 +3078,8 @@ public abstract class AbsListView extends AdapterView implements Te final int motionPosition = mClickMotionPosition; if (adapter != null && mItemCount > 0 && motionPosition != INVALID_POSITION && - motionPosition < adapter.getCount() && sameWindow()) { + motionPosition < adapter.getCount() && sameWindow() && + adapter.isEnabled(motionPosition)) { final View view = getChildAt(motionPosition - mFirstPosition); // If there is no view, something bad happened (the view scrolled off the // screen, etc.) and we should cancel the click