use of com.fanap.podchat.mainmodel.Contact in project pod-chat-android-sdk by FanapSoft.
the class CallPresenter method onContactAdded.
@Override
public void onContactAdded(String content, ChatResponse<ResultAddContact> chatResponse) {
super.onContactAdded(content, chatResponse);
Contact c = chatResponse.getResult().getContact();
view.showMessage(c.getFirstName() + " " + c.getLastName() + " " + c.getCellphoneNumber() + " " + c.getEmail() + " " + (c.getLinkedUser() != null ? c.getLinkedUser().getName() + " " + c.getLinkedUser().getUsername() : "") + " اضافه شد");
}
use of com.fanap.podchat.mainmodel.Contact in project pod-chat-android-sdk by FanapSoft.
the class ExampleUnitTest method sortContactsWithFirstNameTest.
@Test
public void sortContactsWithFirstNameTest() {
ArrayList<Contact> unsorted = new ArrayList<>();
ArrayList<Contact> expected = new ArrayList<>();
ArrayList<Contact> sorted;
Contact contact1 = new Contact();
contact1.setFirstName("Bahar");
contact1.setLastName("Bohloli");
contact1.setHasUser(true);
unsorted.add(contact1);
Contact contact2 = new Contact();
contact2.setFirstName("Ali");
contact2.setHasUser(true);
unsorted.add(contact2);
Contact contact3 = new Contact();
contact3.setFirstName("Bahar");
contact3.setLastName("Alavi");
contact3.setHasUser(true);
unsorted.add(contact3);
Contact contact4 = new Contact();
contact4.setFirstName("Ahmad");
contact4.setLastName("Ahmadian");
contact4.setHasUser(false);
unsorted.add(contact4);
expected.add(contact3);
expected.add(contact1);
expected.add(contact2);
expected.add(contact4);
sorted = new ArrayList<>(unsorted);
Collections.sort(sorted, compareContacts());
Assert.assertEquals(expected, sorted);
}
use of com.fanap.podchat.mainmodel.Contact 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.mainmodel.Contact 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.mainmodel.Contact 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;
}
Aggregations