diff options
author | Linux Build Service Account <lnxbuild@localhost> | 2015-03-14 02:25:44 -0700 |
---|---|---|
committer | Gerrit - the friendly Code Review server <code-review@localhost> | 2015-03-14 02:25:44 -0700 |
commit | 8d2ddd3366f3545ed1ae88d777070c76dd800cbf (patch) | |
tree | 5e215638c61f9d2a52fdb0e7dadf41a5f3cdeb25 | |
parent | f7454db18fdf8652a6bf4528e39a3c01e42ead9d (diff) | |
parent | 61ea801c5ceb5cac09259dd7d1d6422a97a18074 (diff) | |
download | android_packages_apps_ContactsCommon-8d2ddd3366f3545ed1ae88d777070c76dd800cbf.tar.gz android_packages_apps_ContactsCommon-8d2ddd3366f3545ed1ae88d777070c76dd800cbf.tar.bz2 android_packages_apps_ContactsCommon-8d2ddd3366f3545ed1ae88d777070c76dd800cbf.zip |
Merge "Adding ContactLoader support to suppress contact photo loading."
-rw-r--r-- | src/com/android/contacts/common/model/ContactLoader.java | 23 |
1 files changed, 19 insertions, 4 deletions
diff --git a/src/com/android/contacts/common/model/ContactLoader.java b/src/com/android/contacts/common/model/ContactLoader.java index 998fb2d9..59ab292e 100644 --- a/src/com/android/contacts/common/model/ContactLoader.java +++ b/src/com/android/contacts/common/model/ContactLoader.java @@ -318,7 +318,7 @@ public class ContactLoader extends AsyncTaskLoader<Contact> { resultIsCached = true; } else { if (uriCurrentFormat.getLastPathSegment().equals(Constants.LOOKUP_URI_ENCODED)) { - result = loadEncodedContactEntity(uriCurrentFormat); + result = loadEncodedContactEntity(uriCurrentFormat, mLookupUri); } else { result = loadContactEntity(resolver, uriCurrentFormat); } @@ -351,7 +351,22 @@ public class ContactLoader extends AsyncTaskLoader<Contact> { } } - private Contact loadEncodedContactEntity(Uri uri) throws JSONException { + /** + * Parses a {@link Contact} stored as a JSON string in a lookup URI. + * + * @param lookupUri The contact information to parse . + * @return The parsed {@code Contact} information. + * @throws JSONException + */ + public static Contact parseEncodedContactEntity(Uri lookupUri) { + try { + return loadEncodedContactEntity(lookupUri, lookupUri); + } catch (JSONException je) { + return null; + } + } + + private static Contact loadEncodedContactEntity(Uri uri, Uri lookupUri) throws JSONException { final String jsonString = uri.getEncodedFragment(); final JSONObject json = new JSONObject(jsonString); @@ -365,7 +380,7 @@ public class ContactLoader extends AsyncTaskLoader<Contact> { final String photoUri = json.optString(Contacts.PHOTO_URI, null); final Contact contact = new Contact( uri, uri, - mLookupUri, + lookupUri, directoryId, null /* lookupKey */, -1 /* id */, @@ -425,7 +440,7 @@ public class ContactLoader extends AsyncTaskLoader<Contact> { return contact; } - private void processOneRecord(RawContact rawContact, JSONObject item, String mimetype) + private static void processOneRecord(RawContact rawContact, JSONObject item, String mimetype) throws JSONException { final ContentValues itemValues = new ContentValues(); itemValues.put(Data.MIMETYPE, mimetype); |