From 443d758d53d1f7ebb12e8ed39fc6195c9d5ed18d Mon Sep 17 00:00:00 2001 From: Yorke Lee Date: Wed, 31 Jul 2013 19:49:06 -0700 Subject: Don't close cursor manually in PhoneFavoritesTileAdapter This seems to mess up the ability to receive further notifications when the data underlying the cursor changes. The framework will automatically close the cursor when it is no longer needed. Bug: 10117074 Change-Id: I8721c955aebf8fd1826c1eebfb158376d204f0fa --- .../dialer/list/PhoneFavoritesTileAdapter.java | 46 ++++++++++------------ 1 file changed, 21 insertions(+), 25 deletions(-) (limited to 'src') 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); } } -- cgit v1.2.3