summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorAnthony Lee <anthonylee@google.com>2015-01-22 22:20:50 +0000
committerAndroid Git Automerger <android-git-automerger@android.com>2015-01-22 22:20:50 +0000
commit1df0d8d5df845e636cb52f27c4e5d98cb493da14 (patch)
tree0948c92c60b9583a970111d128b17f453b48f09f /src
parent0922849f415e1fc1187480f921208d9bb654bb05 (diff)
parenta69931938e85735a5762ef108a71b10850e59a2d (diff)
am a6993193: am 67ceb111: am 7c35a8e9: Merge "Fix crasher due to IndexOutOfBoundsException" into lmp-mr1-dev
* commit 'a69931938e85735a5762ef108a71b10850e59a2d': Fix crasher due to IndexOutOfBoundsException
Diffstat (limited to 'src')
-rw-r--r--src/com/android/dialer/list/PhoneFavoritesTileAdapter.java2
-rw-r--r--src/com/android/dialer/list/SpeedDialFragment.java14
2 files changed, 14 insertions, 2 deletions
diff --git a/src/com/android/dialer/list/PhoneFavoritesTileAdapter.java b/src/com/android/dialer/list/PhoneFavoritesTileAdapter.java
index 3f670127f..e957c8321 100644
--- a/src/com/android/dialer/list/PhoneFavoritesTileAdapter.java
+++ b/src/com/android/dialer/list/PhoneFavoritesTileAdapter.java
@@ -431,7 +431,7 @@ public class PhoneFavoritesTileAdapter extends BaseAdapter implements
* @param itemIndex Position of the contact in {@link #mContactEntries}.
* @return True if the given index is valid for {@link #mContactEntries}.
*/
- private boolean isIndexInBound(int itemIndex) {
+ public boolean isIndexInBound(int itemIndex) {
return itemIndex >= 0 && itemIndex < mContactEntries.size();
}
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)) {