summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorTyler Gunn <tgunn@google.com>2014-12-05 14:18:33 -0800
committerTyler Gunn <tgunn@google.com>2014-12-05 14:18:33 -0800
commit9e66cdef6e5657cd1fd75e316dec8fb2d94694f0 (patch)
treea7c3b2ec9da0b6b383f0ca0b2e4c5e178a025736 /src
parenta639a24cd7a720761b58d347366a4d46e89db3e0 (diff)
downloadandroid_packages_apps_ContactsCommon-9e66cdef6e5657cd1fd75e316dec8fb2d94694f0.tar.gz
android_packages_apps_ContactsCommon-9e66cdef6e5657cd1fd75e316dec8fb2d94694f0.tar.bz2
android_packages_apps_ContactsCommon-9e66cdef6e5657cd1fd75e316dec8fb2d94694f0.zip
Adding ContactLoader support to suppress contact photo loading.
Bug: 17308163 Change-Id: I3311fd18d666e1de33296fea00f49855b240d938
Diffstat (limited to 'src')
-rw-r--r--src/com/android/contacts/common/model/ContactLoader.java23
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);