use of com.googlecode.gwtphonegap.client.contacts.ContactOrganisation in project gwtphonegap by dankurka.
the class ContactBrowserImpl method fromJSON.
public static Contact fromJSON(ContactsBrowserImpl controller, JSONObject jsonContact) {
ContactBrowserImpl contact = new ContactBrowserImpl(controller);
// simple fields
contact.setId(getFieldAsString(jsonContact.get(FIELD_ID)));
contact.setDisplayName(getFieldAsString(jsonContact.get(CONTACT_DISPLAY_NAME)));
contact.setNickName(getFieldAsString(jsonContact.get(CONTACT_NICK_NAME)));
contact.setNote(getFieldAsString(jsonContact.get(CONTACT_NOTE)));
// birthday
JSONValue dateValue = jsonContact.get(CONTACT_BIRTHDAY);
if (dateValue != null && dateValue.isNumber() != null) {
contact.setBirthDay(new Date((long) dateValue.isNumber().doubleValue()));
}
// contact fields
JSONArray phoneNumberArray = jsonContact.get(CONTACT_PHONE_NUMBERS).isArray();
LightArray<ContactField> phoneNumbers = getContactFieldsForArray(phoneNumberArray);
contact.setPhoneNumbers(phoneNumbers);
JSONArray emailsArray = jsonContact.get(CONTACT_EMAILS).isArray();
LightArray<ContactField> emails = getContactFieldsForArray(emailsArray);
contact.setEmails(emails);
JSONArray imsArray = jsonContact.get(CONTACT_IMS).isArray();
LightArray<ContactField> ims = getContactFieldsForArray(imsArray);
contact.setIms(ims);
JSONArray photosArray = jsonContact.get(CONTACT_PHOTOS).isArray();
LightArray<ContactField> photos = getContactFieldsForArray(photosArray);
contact.setPhotos(photos);
JSONArray categoriesArray = jsonContact.get(CONTACT_CATEGORIES).isArray();
LightArray<ContactField> categories = getContactFieldsForArray(categoriesArray);
contact.setCategories(categories);
JSONArray urlsArray = jsonContact.get(CONTACT_URLS).isArray();
LightArray<ContactField> urls = getContactFieldsForArray(urlsArray);
contact.setUrls(urls);
ContactName name = getName(jsonContact.get(CONTACT_NAME).isObject());
contact.setName(name);
LightArray<ContactAddress> addresses = getAddressArray(jsonContact.get(CONTACT_ADDRESSES).isArray());
contact.setContactAddresses(addresses);
LightArray<ContactOrganisation> organisations = getContactOrganisationArray(jsonContact.get(CONTACT_ORGANISATION).isArray());
contact.setOrganisations(organisations);
return contact;
}
use of com.googlecode.gwtphonegap.client.contacts.ContactOrganisation in project gwtphonegap by dankurka.
the class ContactBrowserImpl method createOrganisation.
private JSONArray createOrganisation(LightArray<ContactOrganisation> organisations) {
JSONArray jsonArray = new JSONArray();
for (int i = 0; i < organisations.length(); i++) {
ContactOrganisation co = organisations.get(i);
JSONObject orga = new JSONObject();
orga.put(ORGANISATION_NAME, getAsJSONString(co.getName()));
orga.put(ORGANISATION_DEPARTMENT, getAsJSONString(co.getDepartment()));
orga.put(ORGANISATION_TITLE, getAsJSONString(co.getTitle()));
orga.put(ORGANISATION_TYPE, getAsJSONString(co.getType()));
orga.put(ORGANISATION_PREF, JSONBoolean.getInstance(co.isPref()));
jsonArray.set(i, orga);
}
return jsonArray;
}
Aggregations