public void saveOrUpdate(Contact contact) { Contact existingContact = getContactById(contact.getUserId()); if (existingContact == null) { addContact(contact); } else { if (Contact.ContactType.DEVICE_AND_APPLOZIC.getValue().equals(existingContact.getDeviceContactType())) { contact.setDeviceContactType(existingContact.getDeviceContactType()); } else if (Contact.ContactType.DEVICE_AND_APPLOZIC.getValue().equals(contact.getDeviceContactType())) { contact.setDeviceContactType(existingContact.getDeviceContactType()); } updateContact(contact); } }
if (contact.getDeviceContactType() != null) { contentValues.put(MobiComDatabaseHelper.DEVICE_CONTACT_TYPE, contact.getDeviceContactType()); contentValues.put(MobiComDatabaseHelper.APPLOZIC_TYPE, contact.isApplozicType() ? 1 : 0);
public void addContact(Contact contact) { try { if (Applozic.getInstance(context).isDeviceContactSync()) { contact.processContactNumbers(context); if (contact.getDeviceContactType() == null) { contact.setDeviceContactType(Contact.ContactType.APPLOZIC.getValue()); } } ContentValues contentValues = prepareContactValues(contact); dbHelper.getWritableDatabase().insert(CONTACT, null, contentValues); } catch (Exception e) { Utils.printLog(context, TAG, "Ignoring duplicate entry for contact"); } finally { dbHelper.close(); } }
@Override public void upsert(Contact contact) { if (Applozic.getInstance(context).isDeviceContactSync()) { contact.processContactNumbers(context); if (contact.getDeviceContactType() == null || TextUtils.isEmpty(contact.getFormattedContactNumber())) { if (contactDatabase.getContactById(contact.getUserId()) == null) { contactDatabase.addContact(contact); } else { contactDatabase.updateContact(contact); } } else { //Need to check if contact no exist if (contactDatabase.getContactByPhoneNo(contact.getFormattedContactNumber()) != null) { contactDatabase.updateContactByPhoneNumber(contact); } else if (contactDatabase.getContactById(contact.getUserId()) == null) { contactDatabase.addContact(contact); } else { contactDatabase.updateContact(contact); } } } else { if (contactDatabase.getContactById(contact.getUserId()) == null) { contactDatabase.addContact(contact); } else { contactDatabase.updateContact(contact); } } }
if (Contact.ContactType.APPLOZIC.getValue().equals(contact.getDeviceContactType()) || Contact.ContactType.DEVICE_AND_APPLOZIC.getValue().equals(contact.getDeviceContactType())) { } else if (Contact.ContactType.DEVICE.getValue().equals(contact.getDeviceContactType())) {