summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorYorke Lee <yorkelee@google.com>2013-07-31 19:49:06 -0700
committerYorke Lee <yorkelee@google.com>2013-07-31 19:49:06 -0700
commit443d758d53d1f7ebb12e8ed39fc6195c9d5ed18d (patch)
tree4eb33c10c342fe4e79a1fb3a13ee3e55fb0c8806
parent1a94e74284791cd9af52ff1717766de9e9515d54 (diff)
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
-rw-r--r--src/com/android/dialer/list/PhoneFavoritesTileAdapter.java46
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);
}
}