Repository: cordova-plugin-contacts Updated Branches: refs/heads/master 5e4ce8a48 -> fd93b078b
CB-7131 Check for profile photo existance Try to resolve profile picture, if it can find it, it returns null Project: http://git-wip-us.apache.org/repos/asf/cordova-plugin-contacts/repo Commit: http://git-wip-us.apache.org/repos/asf/cordova-plugin-contacts/commit/0c179b54 Tree: http://git-wip-us.apache.org/repos/asf/cordova-plugin-contacts/tree/0c179b54 Diff: http://git-wip-us.apache.org/repos/asf/cordova-plugin-contacts/diff/0c179b54 Branch: refs/heads/master Commit: 0c179b546992ba377e4404b7b3ca8f29b9b83b20 Parents: d5c1126 Author: Emilio Blanco <[email protected]> Authored: Fri Aug 8 14:28:26 2014 -0400 Committer: Emilio Blanco <[email protected]> Committed: Wed Aug 13 12:03:00 2014 -0400 ---------------------------------------------------------------------- src/android/ContactAccessorSdk5.java | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/cordova-plugin-contacts/blob/0c179b54/src/android/ContactAccessorSdk5.java ---------------------------------------------------------------------- diff --git a/src/android/ContactAccessorSdk5.java b/src/android/ContactAccessorSdk5.java index 4c81b1b..023d30d 100644 --- a/src/android/ContactAccessorSdk5.java +++ b/src/android/ContactAccessorSdk5.java @@ -436,7 +436,10 @@ public class ContactAccessorSdk5 extends ContactAccessor { } else if (mimetype.equals(ContactsContract.CommonDataKinds.Photo.CONTENT_ITEM_TYPE) && isRequired("photos", populate)) { - photos.put(photoQuery(c, contactId)); + JSONObject photo = photoQuery(c, contactId); + if (photo != null) { + photos.put(photo); + } } } catch (JSONException e) { Log.e(LOG_TAG, e.getMessage(), e); @@ -902,6 +905,17 @@ public class ContactAccessorSdk5 extends ContactAccessor { Uri person = ContentUris.withAppendedId(ContactsContract.Contacts.CONTENT_URI, (Long.valueOf(contactId))); Uri photoUri = Uri.withAppendedPath(person, ContactsContract.Contacts.Photo.CONTENT_DIRECTORY); photo.put("value", photoUri.toString()); + + // Query photo existance + Cursor photoCursor = mApp.getActivity().getContentResolver().query(photoUri, new String[] {ContactsContract.Contacts.Photo.PHOTO}, null, null, null); + if (photoCursor == null) { + return null; + } else { + if (!photoCursor.moveToFirst()) { + photoCursor.close(); + return null; + } + } } catch (JSONException e) { Log.e(LOG_TAG, e.getMessage(), e); } --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
