Skip to content
This repository was archived by the owner on Nov 8, 2018. It is now read-only.

Commit 3f791c4

Browse files
authored
Merge pull request #443 from top-gun007/contact_ambiguity
FIX: Ambiguous contact photo bug resolved.
2 parents 8774179 + 432ef6c commit 3f791c4

File tree

1 file changed

+8
-7
lines changed

1 file changed

+8
-7
lines changed

app/src/main/java/com/peacecorps/pcsa/circle_of_trust/ContactPhotoLoader.java

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -60,21 +60,22 @@ protected void onPostExecute(Bitmap bitmap) {
6060
private Integer fetchThumbnailId(String phoneNumber) {
6161
ContentResolver contentResolver = context.getContentResolver();
6262

63-
final Uri uri = Uri.withAppendedPath(ContactsContract.CommonDataKinds.Phone.CONTENT_FILTER_URI, Uri.encode(phoneNumber));
64-
final Cursor cursor = contentResolver.query(uri, PHOTO_ID_PROJECTION, null, null, ContactsContract.Contacts.DISPLAY_NAME + " ASC");
63+
final Uri uri = Uri.withAppendedPath(ContactsContract.PhoneLookup.CONTENT_FILTER_URI, Uri.encode(phoneNumber));
64+
65+
final Cursor cursor = contentResolver.query(uri, PHOTO_ID_PROJECTION, null, null, null);
6566

6667
try {
6768
Integer thumbnailId = null;
68-
if (cursor!= null && cursor.moveToFirst()) {
69+
if (cursor != null && cursor.moveToFirst()) {
6970
thumbnailId = cursor.getInt(cursor.getColumnIndex(ContactsContract.Contacts.PHOTO_ID));
7071
}
7172
return thumbnailId;
7273
} catch (Exception e) {
7374
Log.e(TAG, "Unable to load thumbnail ID", e);
7475
return null;
7576
} finally {
76-
if(cursor !=null)
77-
cursor.close();
77+
if (cursor != null)
78+
cursor.close();
7879
}
7980

8081
}
@@ -103,8 +104,8 @@ private Bitmap fetchThumbnail(final int thumbnailId) {
103104
Log.e(TAG, "Unable to load thumbnail image", e);
104105
return null;
105106
} finally {
106-
if(cursor != null)
107-
cursor.close();
107+
if (cursor != null)
108+
cursor.close();
108109
}
109110

110111
}

0 commit comments

Comments
 (0)