From b339cc5bcbafbc5b9cf184c6f87b4eb466386ea6 Mon Sep 17 00:00:00 2001 From: Alan Viverette Date: Mon, 12 Aug 2013 13:29:15 -0700 Subject: [PATCH] Not create context menu when mouse right click outside list/grid items Even if mouse right click outside of list/grid items, a context menu is made. But there is no item of the list, so a context menu info is null. Then, NullPointerException happens at onCreateContextMenu() using a context menu info. For fixing the problem, check mTouchMoude and mMotionPosition to distingusih where is clicked, on a list item or not, before performButtonActionOnTouchDown() which makes a context menu. Manually merged from AOSP contribution. Change-Id: I778be73df36abbfd4ba9534d8e7a1ece6844ed40 Author: henrik baard --- 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 0ed846bd71bde..07198c758357d 100644 --- a/core/java/android/widget/AbsListView.java +++ b/core/java/android/widget/AbsListView.java @@ -3485,7 +3485,8 @@ public abstract class AbsListView extends AdapterView implements Te mLastY = Integer.MIN_VALUE; } - if (performButtonActionOnTouchDown(ev) && (mTouchMode == TOUCH_MODE_DOWN)) { + if (mTouchMode == TOUCH_MODE_DOWN && mMotionPosition != INVALID_POSITION + && performButtonActionOnTouchDown(ev)) { removeCallbacks(mPendingCheckForTap); } }