From a1c02690270329ddf3fe8b777c2ad774c82a08b1 Mon Sep 17 00:00:00 2001 From: Julia Reynolds Date: Tue, 19 May 2020 10:26:03 -0400 Subject: [PATCH] Map local context menu to the correct item Since the position of the item might have changed if ohter items were deleted Test: manual: delete item 0/2, item 2/2, then 1/2 Fixes: 156716919 Change-Id: I989a064d3a3f89b5c2692d5a687d759c842e080c --- .../notification/history/NotificationHistoryAdapter.java | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/com/android/settings/notification/history/NotificationHistoryAdapter.java b/src/com/android/settings/notification/history/NotificationHistoryAdapter.java index afe36ef0589..4a5c627eb28 100644 --- a/src/com/android/settings/notification/history/NotificationHistoryAdapter.java +++ b/src/com/android/settings/notification/history/NotificationHistoryAdapter.java @@ -98,7 +98,8 @@ public class NotificationHistoryAdapter extends public boolean performAccessibilityAction(View host, int action, Bundle args) { super.performAccessibilityAction(host, action, args); if (action == AccessibilityNodeInfo.AccessibilityAction.ACTION_DISMISS.getId()) { - onItemSwipeDeleted(position); + int currPosition = mValues.indexOf(hn); + onItemSwipeDeleted(currPosition); return true; } return false; @@ -119,6 +120,11 @@ public class NotificationHistoryAdapter extends @Override public void onItemSwipeDeleted(int position) { + if (position > (mValues.size() - 1)) { + Slog.d(TAG, "Tried to swipe element out of list: position: " + position + + " size? " + mValues.size()); + return; + } HistoricalNotification hn = mValues.remove(position); if (hn != null) { try {