Search in sources :

Example 1 with Contact

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() : "") + " اضافه شد");
}
Also used : ResultContact(com.fanap.podchat.model.ResultContact) ResultAddContact(com.fanap.podchat.model.ResultAddContact) RequestGetContact(com.fanap.podchat.requestobject.RequestGetContact) Contact(com.fanap.podchat.mainmodel.Contact)

Example 2 with Contact

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);
}
Also used : ArrayList(java.util.ArrayList) Contact(com.fanap.podchat.mainmodel.Contact) PhoneContact(com.fanap.podchat.cachemodel.PhoneContact) Test(org.junit.Test)

Example 3 with Contact

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);
    });
}
Also used : Calendar(java.util.Calendar) ArrayList(java.util.ArrayList) SimpleDateFormat(java.text.SimpleDateFormat) CacheContact(com.fanap.podchat.cachemodel.CacheContact) Date(java.util.Date) IOException(java.io.IOException) ParseException(java.text.ParseException) ResultContact(com.fanap.podchat.model.ResultContact) BlockedContact(com.fanap.podchat.mainmodel.BlockedContact) RequestSearchContact(com.fanap.podchat.mainmodel.RequestSearchContact) Contact(com.fanap.podchat.mainmodel.Contact) CacheContact(com.fanap.podchat.cachemodel.CacheContact) CacheBlockedContact(com.fanap.podchat.cachemodel.CacheBlockedContact)

Example 4 with Contact

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;
}
Also used : ArrayList(java.util.ArrayList) CacheContact(com.fanap.podchat.cachemodel.CacheContact) ResultContact(com.fanap.podchat.model.ResultContact) BlockedContact(com.fanap.podchat.mainmodel.BlockedContact) RequestSearchContact(com.fanap.podchat.mainmodel.RequestSearchContact) Contact(com.fanap.podchat.mainmodel.Contact) CacheContact(com.fanap.podchat.cachemodel.CacheContact) CacheBlockedContact(com.fanap.podchat.cachemodel.CacheBlockedContact) NonNull(android.support.annotation.NonNull)

Example 5 with Contact

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;
}
Also used : ArrayList(java.util.ArrayList) CacheContact(com.fanap.podchat.cachemodel.CacheContact) ResultContact(com.fanap.podchat.model.ResultContact) BlockedContact(com.fanap.podchat.mainmodel.BlockedContact) RequestSearchContact(com.fanap.podchat.mainmodel.RequestSearchContact) Contact(com.fanap.podchat.mainmodel.Contact) CacheContact(com.fanap.podchat.cachemodel.CacheContact) CacheBlockedContact(com.fanap.podchat.cachemodel.CacheBlockedContact) NonNull(android.support.annotation.NonNull)

Aggregations

Contact (com.fanap.podchat.mainmodel.Contact)30 ResultContact (com.fanap.podchat.model.ResultContact)22 ArrayList (java.util.ArrayList)20 RequestSearchContact (com.fanap.podchat.mainmodel.RequestSearchContact)17 BlockedContact (com.fanap.podchat.mainmodel.BlockedContact)15 CacheBlockedContact (com.fanap.podchat.cachemodel.CacheBlockedContact)13 CacheContact (com.fanap.podchat.cachemodel.CacheContact)13 Test (org.junit.Test)12 NonNull (android.support.annotation.NonNull)11 RequestGetContact (com.fanap.podchat.requestobject.RequestGetContact)9 LargeTest (android.support.test.filters.LargeTest)8 Invitee (com.fanap.podchat.mainmodel.Invitee)8 ChatResponse (com.fanap.podchat.model.ChatResponse)8 SimpleDateFormat (java.text.SimpleDateFormat)6 Calendar (java.util.Calendar)6 Date (java.util.Date)6 ChatListener (com.fanap.podchat.chat.ChatListener)5 AssistantVo (com.fanap.podchat.chat.assistant.model.AssistantVo)5 ResultAddContact (com.fanap.podchat.model.ResultAddContact)5 RegisterAssistantRequest (com.fanap.podchat.chat.assistant.request_model.RegisterAssistantRequest)4