use of com.fanap.podchat.cachemodel.CacheContact in project pod-chat-android-sdk by FanapSoft.
the class MessageDatabaseHelper method saveContacts.
public void saveContacts(@NonNull List<Contact> contacts, int expireAmount) {
worker(() -> {
List<CacheContact> cacheContacts = new ArrayList<>();
for (Contact contact : contacts) {
SimpleDateFormat format = new SimpleDateFormat("dd/MM/yyyy hh:mm:ss", Locale.getDefault());
Calendar c = Calendar.getInstance();
c.setTime(new Date());
c.add(Calendar.SECOND, expireAmount);
String expireDate = format.format(c.getTime());
CacheContact cacheContact = null;
try {
cacheContact = getCacheContact(expireDate, contact, contact.getBlocked(), contact.getLinkedUser());
} catch (Exception e) {
captureException("SAVE CONTACT", e);
continue;
}
cacheContacts.add(cacheContact);
}
messageDao.insertContacts(cacheContacts);
});
}
use of com.fanap.podchat.cachemodel.CacheContact in project pod-chat-android-sdk by FanapSoft.
the class MessageDatabaseHelper method getContactsByFirstAndLast.
@NonNull
public List<Contact> getContactsByFirstAndLast(String firstName, String lastName) {
List<Contact> contacts = new ArrayList<>();
List<CacheContact> cacheContacts = messageDao.getContactsByFirstAndLast(firstName, lastName);
if (cacheContacts != null) {
for (CacheContact cacheContact : cacheContacts) {
Contact contact = new Contact(cacheContact.getId(), cacheContact.getFirstName(), cacheContact.getUserId(), cacheContact.getLastName(), cacheContact.getBlocked(), cacheContact.getCreationDate(), cacheContact.getLinkedUser(), cacheContact.getCellphoneNumber(), cacheContact.getEmail(), cacheContact.getUniqueId(), cacheContact.getNotSeenDuration(), cacheContact.isHasUser());
contacts.add(contact);
}
}
return contacts;
}
use of com.fanap.podchat.cachemodel.CacheContact in project pod-chat-android-sdk by FanapSoft.
the class MessageDatabaseHelper method getContactsByEmail.
@NonNull
public List<Contact> getContactsByEmail(String email) {
List<Contact> contacts = new ArrayList<>();
List<CacheContact> cacheContacts = messageDao.getContactsByEmail(email);
if (cacheContacts != null) {
for (CacheContact cacheContact : cacheContacts) {
Contact contact = new Contact(cacheContact.getId(), cacheContact.getFirstName(), cacheContact.getUserId(), cacheContact.getLastName(), cacheContact.getBlocked(), cacheContact.getCreationDate(), cacheContact.getLinkedUser(), cacheContact.getCellphoneNumber(), cacheContact.getEmail(), cacheContact.getUniqueId(), cacheContact.getNotSeenDuration(), cacheContact.isHasUser());
contacts.add(contact);
}
}
return contacts;
}
use of com.fanap.podchat.cachemodel.CacheContact in project pod-chat-android-sdk by FanapSoft.
the class MessageDatabaseHelper method getContactByCell.
@NonNull
public List<Contact> getContactByCell(String cellphoneNumber) {
List<Contact> contacts = new ArrayList<>();
List<CacheContact> cacheContacts = messageDao.getContactByCell(cellphoneNumber);
if (cacheContacts != null) {
for (CacheContact cacheContact : cacheContacts) {
Contact contact = new Contact(cacheContact.getId(), cacheContact.getFirstName(), cacheContact.getUserId(), cacheContact.getLastName(), cacheContact.getBlocked(), cacheContact.getCreationDate(), cacheContact.getLinkedUser(), cacheContact.getCellphoneNumber(), cacheContact.getEmail(), cacheContact.getUniqueId(), cacheContact.getNotSeenDuration(), cacheContact.isHasUser());
contacts.add(contact);
}
}
return contacts;
}
use of com.fanap.podchat.cachemodel.CacheContact in project pod-chat-android-sdk by FanapSoft.
the class MessageDatabaseHelper method saveContact.
public void saveContact(@NonNull Contact contact, int expireSecond) {
worker(() -> {
SimpleDateFormat dateFormat = new SimpleDateFormat("dd/MM/yyyy hh:mm:ss", Locale.getDefault());
Calendar c = Calendar.getInstance();
c.setTime(new Date());
c.add(Calendar.DATE, expireSecond);
String expireDate = dateFormat.format(c.getTime());
CacheContact cacheContact = getCacheContact(expireDate, contact, contact.getBlocked(), contact.getLinkedUser());
messageDao.insertContact(cacheContact);
});
}
Aggregations