Loading src/com/android/contacts/model/ContactLoader.java +30 −15 Original line number Diff line number Diff line Loading @@ -55,6 +55,7 @@ import com.google.common.collect.ImmutableMap; import com.google.common.collect.Maps; import com.google.common.collect.Sets; import org.json.JSONArray; import org.json.JSONException; import org.json.JSONObject; Loading Loading @@ -405,8 +406,28 @@ public class ContactLoader extends AsyncTaskLoader<Contact> { final Iterator keys = items.keys(); while (keys.hasNext()) { final String mimetype = (String) keys.next(); final JSONObject item = items.getJSONObject(mimetype); // Could be single object or array. final JSONObject obj = items.optJSONObject(mimetype); if (obj == null) { final JSONArray array = items.getJSONArray(mimetype); for (int i = 0; i < array.length(); i++) { final JSONObject item = array.getJSONObject(i); processOneRecord(rawContact, item, mimetype); } } else { processOneRecord(rawContact, obj, mimetype); } } contact.setRawContacts(new ImmutableList.Builder<RawContact>() .add(rawContact) .build()); return contact; } private void processOneRecord(RawContact rawContact, JSONObject item, String mimetype) throws JSONException { final ContentValues itemValues = new ContentValues(); itemValues.put(Data.MIMETYPE, mimetype); itemValues.put(Data._ID, -1); Loading @@ -424,12 +445,6 @@ public class ContactLoader extends AsyncTaskLoader<Contact> { rawContact.addDataItemValues(itemValues); } contact.setRawContacts(new ImmutableList.Builder<RawContact>() .add(rawContact) .build()); return contact; } private Contact loadContactEntity(ContentResolver resolver, Uri contactUri) { Uri entityUri = Uri.withAppendedPath(contactUri, Contacts.Entity.CONTENT_DIRECTORY); Cursor cursor = resolver.query(entityUri, ContactQuery.COLUMNS, null, null, Loading Loading
src/com/android/contacts/model/ContactLoader.java +30 −15 Original line number Diff line number Diff line Loading @@ -55,6 +55,7 @@ import com.google.common.collect.ImmutableMap; import com.google.common.collect.Maps; import com.google.common.collect.Sets; import org.json.JSONArray; import org.json.JSONException; import org.json.JSONObject; Loading Loading @@ -405,8 +406,28 @@ public class ContactLoader extends AsyncTaskLoader<Contact> { final Iterator keys = items.keys(); while (keys.hasNext()) { final String mimetype = (String) keys.next(); final JSONObject item = items.getJSONObject(mimetype); // Could be single object or array. final JSONObject obj = items.optJSONObject(mimetype); if (obj == null) { final JSONArray array = items.getJSONArray(mimetype); for (int i = 0; i < array.length(); i++) { final JSONObject item = array.getJSONObject(i); processOneRecord(rawContact, item, mimetype); } } else { processOneRecord(rawContact, obj, mimetype); } } contact.setRawContacts(new ImmutableList.Builder<RawContact>() .add(rawContact) .build()); return contact; } private void processOneRecord(RawContact rawContact, JSONObject item, String mimetype) throws JSONException { final ContentValues itemValues = new ContentValues(); itemValues.put(Data.MIMETYPE, mimetype); itemValues.put(Data._ID, -1); Loading @@ -424,12 +445,6 @@ public class ContactLoader extends AsyncTaskLoader<Contact> { rawContact.addDataItemValues(itemValues); } contact.setRawContacts(new ImmutableList.Builder<RawContact>() .add(rawContact) .build()); return contact; } private Contact loadContactEntity(ContentResolver resolver, Uri contactUri) { Uri entityUri = Uri.withAppendedPath(contactUri, Contacts.Entity.CONTENT_DIRECTORY); Cursor cursor = resolver.query(entityUri, ContactQuery.COLUMNS, null, null, Loading