diff options
author | Linux Build Service Account <lnxbuild@localhost> | 2015-03-16 02:46:02 -0700 |
---|---|---|
committer | Gerrit - the friendly Code Review server <code-review@localhost> | 2015-03-16 02:46:02 -0700 |
commit | cafd87d3eb7612ba23a8019fc27d84b13873f616 (patch) | |
tree | 168ae58fa5284af9933e465290e0c6fc4ce04966 | |
parent | 5262be53def9e78c30b1ebd379063cffe2e6a658 (diff) | |
parent | 698f9a627e5f538db8bf95f4b1992ff6beb9bbf7 (diff) | |
download | android_packages_apps_Dialer-cafd87d3eb7612ba23a8019fc27d84b13873f616.tar.gz android_packages_apps_Dialer-cafd87d3eb7612ba23a8019fc27d84b13873f616.tar.bz2 android_packages_apps_Dialer-cafd87d3eb7612ba23a8019fc27d84b13873f616.zip |
Merge "Fix crasher due to IndexOutOfBoundsException."
-rw-r--r-- | src/com/android/dialer/list/PhoneFavoritesTileAdapter.java | 2 | ||||
-rw-r--r-- | src/com/android/dialer/list/SpeedDialFragment.java | 14 |
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 26f888f5f..62e7dce08 100644 --- a/src/com/android/dialer/list/PhoneFavoritesTileAdapter.java +++ b/src/com/android/dialer/list/PhoneFavoritesTileAdapter.java @@ -449,7 +449,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 4572404fc..03613d017 100644 --- a/src/com/android/dialer/list/SpeedDialFragment.java +++ b/src/com/android/dialer/list/SpeedDialFragment.java @@ -317,6 +317,12 @@ public class SpeedDialFragment extends AnalyticsFragment implements OnItemClickL 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: " @@ -325,7 +331,6 @@ public class SpeedDialFragment extends AnalyticsFragment implements OnItemClickL mItemIdTopMap.put(itemId, child.getTop()); mItemIdLeftMap.put(itemId, child.getLeft()); } - mItemIdTopMap.put(KEY_REMOVED_ITEM_HEIGHT, removedItemHeight); } @@ -353,6 +358,13 @@ public class SpeedDialFragment extends AnalyticsFragment implements OnItemClickL 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)) { |