public boolean isContactPresent(String contactNumber, Contact.ContactType contactType) { try { SQLiteDatabase db = dbHelper.getWritableDatabase(); final Cursor cursor = db.rawQuery("SELECT COUNT(*) FROM contact where " + MobiComDatabaseHelper.CONTACT_NO + " = ? AND " + MobiComDatabaseHelper.DEVICE_CONTACT_TYPE + " = ? ", new String[]{contactNumber, String.valueOf(contactType.getValue())}); cursor.moveToFirst(); boolean present = cursor.getInt(0) > 0; if (cursor != null) { cursor.close(); } dbHelper.close(); return present; } catch (Exception ex) { } return false; }
public List<Contact> getContacts(Contact.ContactType contactType) { SQLiteDatabase db = dbHelper.getWritableDatabase(); String structuredNameWhere = MobiComDatabaseHelper.CONTACT_TYPE + " = ?"; Cursor cursor = db.query(CONTACT, null, structuredNameWhere, new String[]{String.valueOf(contactType.getValue())}, null, null, MobiComDatabaseHelper.FULL_NAME + " asc"); List<Contact> contactList = getContactList(cursor); cursor.close(); dbHelper.close(); return contactList; }
contactDatabase.updatePhoneContactDisplayName(formattedPhoneNumber, displayName, Contact.ContactType.DEVICE_AND_APPLOZIC.getValue()); newContact.setContactNumber(formattedPhoneNumber); newContact.setUserId(lookupKey); newContact.setDeviceContactType(Contact.ContactType.DEVICE.getValue()); newContact.setFullName(displayName); newContact.setPhoneDisplayName(displayName);
if (Contact.ContactType.APPLOZIC.getValue().equals(contact.getDeviceContactType()) || Contact.ContactType.DEVICE_AND_APPLOZIC.getValue().equals(contact.getDeviceContactType())) { List<Contact> contactDevice = getContactsByContactNumberAndType(contact.getFormattedContactNumber(), Contact.ContactType.DEVICE.getValue()); for (Contact c : contactDevice) { contact.setPhoneDisplayName(c.getPhoneDisplayName()); contact.setDeviceContactType(Contact.ContactType.DEVICE_AND_APPLOZIC.getValue()); } else if (Contact.ContactType.DEVICE.getValue().equals(contact.getDeviceContactType())) { List<Contact> contactListApplozic = getContactsByContactNumberAndType(contact.getFormattedContactNumber(), Contact.ContactType.APPLOZIC.getValue()); for (Contact c : contactListApplozic) { c.setDeviceContactType(Contact.ContactType.DEVICE_AND_APPLOZIC.getValue()); updateContact(c); updatePhoneContactDisplayName(contact.getFormattedContactNumber(), contact.getPhoneDisplayName(), Contact.ContactType.DEVICE_AND_APPLOZIC.getValue()); deleteContactByPhoneNumber(contact.getFormattedContactNumber(), Contact.ContactType.DEVICE.getValue()); deleteContactByPhoneNumber(contact.getFormattedContactNumber(), Contact.ContactType.APPLOZIC.getValue());
contact.setBlocked(syncUserBlockedFeed.getUserBlocked()); if (Applozic.getInstance(context).isDeviceContactSync()) { contact.setDeviceContactType(Contact.ContactType.APPLOZIC.getValue()); contact.setBlockedBy(syncUserBlockByFeed.getUserBlocked()); if (Applozic.getInstance(context).isDeviceContactSync()) { contact.setDeviceContactType(Contact.ContactType.APPLOZIC.getValue());
public synchronized Contact getContactFromUserDetail(UserDetail userDetail, Contact.ContactType contactType) { Contact contact = new Contact(); contact.setUserId(userDetail.getUserId()); contact.setContactNumber(userDetail.getPhoneNumber()); contact.setConnected(userDetail.isConnected()); contact.setStatus(userDetail.getStatusMessage()); if (!TextUtils.isEmpty(userDetail.getDisplayName())) { contact.setFullName(userDetail.getDisplayName()); } contact.setLastSeenAt(userDetail.getLastSeenAtTime()); contact.setUserTypeId(userDetail.getUserTypeId()); contact.setUnreadCount(0); contact.setLastMessageAtTime(userDetail.getLastMessageAtTime()); contact.setMetadata(userDetail.getMetadata()); contact.setRoleType(userDetail.getRoleType()); contact.setDeletedAtTime(userDetail.getDeletedAtTime()); if (!TextUtils.isEmpty(userDetail.getImageLink())) { contact.setImageURL(userDetail.getImageLink()); } if (Applozic.getInstance(context).isDeviceContactSync()) { contact.setDeviceContactType(contactType.getValue()); } else { contact.setContactType(contactType.getValue()); } baseContactService.upsert(contact); return contact; }
public synchronized void processUser(UserDetail userDetail, Contact.ContactType contactType) { Contact contact = new Contact(); contact.setUserId(userDetail.getUserId()); contact.setContactNumber(userDetail.getPhoneNumber()); contact.setConnected(userDetail.isConnected()); contact.setStatus(userDetail.getStatusMessage()); if (!TextUtils.isEmpty(userDetail.getDisplayName())) { contact.setFullName(userDetail.getDisplayName()); } contact.setLastSeenAt(userDetail.getLastSeenAtTime()); contact.setUserTypeId(userDetail.getUserTypeId()); contact.setUnreadCount(0); contact.setLastMessageAtTime(userDetail.getLastMessageAtTime()); contact.setMetadata(userDetail.getMetadata()); contact.setRoleType(userDetail.getRoleType()); contact.setDeletedAtTime(userDetail.getDeletedAtTime()); if (!TextUtils.isEmpty(userDetail.getImageLink())) { contact.setImageURL(userDetail.getImageLink()); } if (Applozic.getInstance(context).isDeviceContactSync()) { contact.setDeviceContactType(contactType.getValue()); } else { contact.setContactType(contactType.getValue()); } baseContactService.upsert(contact); }
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(); } }
public boolean isDeviceContact() { return (deviceContactType != null && ContactType.DEVICE.getValue().equals(deviceContactType)); }
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); } }