Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 7c35a8e9 authored by Anthony Lee's avatar Anthony Lee Committed by Android (Google) Code Review
Browse files

Merge "Fix crasher due to IndexOutOfBoundsException" into lmp-mr1-dev

parents 2752f32c e48124fa
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -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();
    }

+13 −1
Original line number Diff line number Diff line
@@ -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)) {