diff options
author | Yorke Lee <yorkelee@google.com> | 2013-08-01 15:00:55 +0000 |
---|---|---|
committer | Android (Google) Code Review <android-gerrit@google.com> | 2013-08-01 15:00:55 +0000 |
commit | ff6d2798dcd3c4b9a75537c4e69a98ba35508dc1 (patch) | |
tree | cb8147f704b30528d8ebfcb758480af6d3484fe9 /src | |
parent | 8308bb61b1c6f1605bddb340d3302064eb244e5a (diff) | |
parent | 443d758d53d1f7ebb12e8ed39fc6195c9d5ed18d (diff) |
Merge "Don't close cursor manually in PhoneFavoritesTileAdapter"
Diffstat (limited to 'src')
-rw-r--r-- | src/com/android/dialer/list/PhoneFavoritesTileAdapter.java | 46 |
1 files changed, 21 insertions, 25 deletions
diff --git a/src/com/android/dialer/list/PhoneFavoritesTileAdapter.java b/src/com/android/dialer/list/PhoneFavoritesTileAdapter.java index 29ce031cb..58ebcff78 100644 --- a/src/com/android/dialer/list/PhoneFavoritesTileAdapter.java +++ b/src/com/android/dialer/list/PhoneFavoritesTileAdapter.java @@ -213,31 +213,27 @@ public class PhoneFavoritesTileAdapter extends BaseAdapter { */ private void saveCursorToCache(Cursor cursor) { mContactEntries.clear(); - try { - cursor.moveToPosition(-1); - while (cursor.moveToNext()) { - final long id = cursor.getLong(mIdIndex); - final String photoUri = cursor.getString(mPhotoUriIndex); - final String lookupKey = cursor.getString(mLookupIndex); - - final ContactEntry contact = new ContactEntry(); - final String name = cursor.getString(mNameIndex); - contact.name = (name != null) ? name : mResources.getString(R.string.missing_name); - contact.status = cursor.getString(mStatusIndex); - contact.photoUri = (photoUri != null ? Uri.parse(photoUri) : null); - contact.lookupKey = ContentUris.withAppendedId( - Uri.withAppendedPath(Contacts.CONTENT_LOOKUP_URI, lookupKey), id); - - // Set phone number and label - final int phoneNumberType = cursor.getInt(mPhoneNumberTypeIndex); - final String phoneNumberCustomLabel = cursor.getString(mPhoneNumberLabelIndex); - contact.phoneLabel = (String) Phone.getTypeLabel(mResources, phoneNumberType, - phoneNumberCustomLabel); - contact.phoneNumber = cursor.getString(mPhoneNumberIndex); - mContactEntries.add(contact); - } - } finally { - cursor.close(); + cursor.moveToPosition(-1); + while (cursor.moveToNext()) { + final long id = cursor.getLong(mIdIndex); + final String photoUri = cursor.getString(mPhotoUriIndex); + final String lookupKey = cursor.getString(mLookupIndex); + + final ContactEntry contact = new ContactEntry(); + final String name = cursor.getString(mNameIndex); + contact.name = (name != null) ? name : mResources.getString(R.string.missing_name); + contact.status = cursor.getString(mStatusIndex); + contact.photoUri = (photoUri != null ? Uri.parse(photoUri) : null); + contact.lookupKey = ContentUris.withAppendedId( + Uri.withAppendedPath(Contacts.CONTENT_LOOKUP_URI, lookupKey), id); + + // Set phone number and label + final int phoneNumberType = cursor.getInt(mPhoneNumberTypeIndex); + final String phoneNumberCustomLabel = cursor.getString(mPhoneNumberLabelIndex); + contact.phoneLabel = (String) Phone.getTypeLabel(mResources, phoneNumberType, + phoneNumberCustomLabel); + contact.phoneNumber = cursor.getString(mPhoneNumberIndex); + mContactEntries.add(contact); } } |