summaryrefslogtreecommitdiffstats
path: root/src/com/android/dialer/list/SpeedDialFragment.java
diff options
context:
space:
mode:
authorAnthony Lee <anthonylee@google.com>2015-01-22 07:56:19 -0800
committerAnthony Lee <anthonylee@google.com>2015-01-22 08:57:32 -0800
commite48124fa2d295c68cdb95f962ef8bd6d35a7c145 (patch)
tree150990e26216bfeaf1f6093571cdddd3d9768c4a /src/com/android/dialer/list/SpeedDialFragment.java
parent1eb16ea1adca302ff19f64d6ae55e586194a6127 (diff)
downloadandroid_packages_apps_Dialer-e48124fa2d295c68cdb95f962ef8bd6d35a7c145.tar.gz
android_packages_apps_Dialer-e48124fa2d295c68cdb95f962ef8bd6d35a7c145.tar.bz2
android_packages_apps_Dialer-e48124fa2d295c68cdb95f962ef8bd6d35a7c145.zip
Fix crasher due to IndexOutOfBoundsException
Make sure that we check for the index to exist in the list before we query for it. The problem is that the index is grabbed from the listview but then applied to the contact entry arraylist. It is possible that these two are out of temporarily out of sync. This check will make sure that we do not throw an exception in those cases. Bug: 19103509 Change-Id: Iba620ec859866b9f8bfc2614a17b1b1a11037230
Diffstat (limited to 'src/com/android/dialer/list/SpeedDialFragment.java')
-rw-r--r--src/com/android/dialer/list/SpeedDialFragment.java14
1 files changed, 13 insertions, 1 deletions
diff --git a/src/com/android/dialer/list/SpeedDialFragment.java b/src/com/android/dialer/list/SpeedDialFragment.java
index a42031677..63f1f34c6 100644
--- a/src/com/android/dialer/list/SpeedDialFragment.java
+++ b/src/com/android/dialer/list/SpeedDialFragment.java
@@ -312,6 +312,12 @@ public class SpeedDialFragment extends Fragment implements OnItemClickListener,
for (int i = 0; i < mListView.getChildCount(); i++) {
final View child = mListView.getChildAt(i);
final int position = firstVisiblePosition + i;
+ // Since we are getting the position from mListView and then querying
+ // mContactTileAdapter, its very possible that things are out of sync
+ // and we might index out of bounds. Let's make sure that this doesn't happen.
+ if (!mContactTileAdapter.isIndexInBound(position)) {
+ continue;
+ }
final long itemId = mContactTileAdapter.getItemId(position);
if (DEBUG) {
Log.d(TAG, "Saving itemId: " + itemId + " for listview child " + i + " Top: "
@@ -320,7 +326,6 @@ public class SpeedDialFragment extends Fragment implements OnItemClickListener,
mItemIdTopMap.put(itemId, child.getTop());
mItemIdLeftMap.put(itemId, child.getLeft());
}
-
mItemIdTopMap.put(KEY_REMOVED_ITEM_HEIGHT, removedItemHeight);
}
@@ -348,6 +353,13 @@ public class SpeedDialFragment extends Fragment implements OnItemClickListener,
final View child = mListView.getChildAt(i);
int position = firstVisiblePosition + i;
+ // Since we are getting the position from mListView and then querying
+ // mContactTileAdapter, its very possible that things are out of sync
+ // and we might index out of bounds. Let's make sure that this doesn't happen.
+ if (!mContactTileAdapter.isIndexInBound(position)) {
+ continue;
+ }
+
final long itemId = mContactTileAdapter.getItemId(position);
if (containsId(idsInPlace, itemId)) {