Search in sources :

Example 1 with ResultContact

use of com.fanap.podchat.model.ResultContact in project pod-chat-android-sdk by FanapSoft.

the class IntegrationTest method getContacts.

@Test
public void getContacts() {
    chatListeners = new ChatListener() {

        @Override
        public void onGetContacts(String content, ChatResponse<ResultContact> response) {
            System.out.println("Received contact: " + content);
            contactContent = content;
            resumeProcess();
        }
    };
    chat.addListener(chatListeners);
    RequestGetContact request = new RequestGetContact.Builder().count(50).offset(0).build();
    chat.getContacts(request, null);
    pauseProcess();
    System.out.println("Received contact: " + contactContent);
}
Also used : ResultContact(com.fanap.podchat.model.ResultContact) ChatListener(com.fanap.podchat.chat.ChatListener) RequestGetContact(com.fanap.podchat.requestobject.RequestGetContact) Test(org.junit.Test) LargeTest(android.support.test.filters.LargeTest)

Example 2 with ResultContact

use of com.fanap.podchat.model.ResultContact in project pod-chat-android-sdk by FanapSoft.

the class ContactCacheTest method populateContactsFromServer.

public void populateContactsFromServer() {
    chatListeners = new ChatListener() {

        @Override
        public void onGetContacts(String content, ChatResponse<ResultContact> response) {
            if (!response.isCache()) {
                System.out.println("Received List: " + content);
                serverContacts.addAll(response.getResult().getContacts());
                chat.removeListener(chatListeners);
                resumeProcess();
            }
        }
    };
    chat.setListener(chatListeners);
    RequestGetContact request = new RequestGetContact.Builder().count(50).offset(0).build();
    chat.getContacts(request, null);
    pauseProcess();
    System.out.println("Received List: " + serverContacts.size());
}
Also used : ResultContact(com.fanap.podchat.model.ResultContact) ChatListener(com.fanap.podchat.chat.ChatListener) RequestGetContact(com.fanap.podchat.requestobject.RequestGetContact)

Example 3 with ResultContact

use of com.fanap.podchat.model.ResultContact in project pod-chat-android-sdk by FanapSoft.

the class ChatCore method publishContactResult.

private void publishContactResult(String uniqueId, long offset, ArrayList<Contact> cacheContactsList, int contentCount) {
    ChatResponse<ResultContact> chatResponse = new ChatResponse<>();
    ResultContact resultContact = new ResultContact();
    resultContact.setContacts(cacheContactsList);
    chatResponse.setResult(resultContact);
    chatResponse.setCache(true);
    chatResponse.setUniqueId(uniqueId);
    long nextOffset = cacheContactsList.size() + offset;
    boolean hasNext = nextOffset < contentCount;
    resultContact.setContentCount(contentCount);
    resultContact.setNextOffset(nextOffset);
    resultContact.setHasNext(hasNext);
    String contactJson = gson.toJson(chatResponse);
    listenerManager.callOnGetContacts(contactJson, chatResponse);
    if (sentryResponseLog) {
        showLog("CACHE_GET_CONTACT", contactJson);
    } else {
        showLog("CACHE_GET_CONTACT");
    }
}
Also used : ResultContact(com.fanap.podchat.model.ResultContact) ChatResponse(com.fanap.podchat.model.ChatResponse)

Example 4 with ResultContact

use of com.fanap.podchat.model.ResultContact in project pod-chat-android-sdk by FanapSoft.

the class ChatCore method reformatGetContactResponse.

@NonNull
private ChatResponse<ResultContact> reformatGetContactResponse(ChatMessage chatMessage, Callback callback) {
    ResultContact resultContact = new ResultContact();
    ChatResponse<ResultContact> outPutContact = new ChatResponse<>();
    ArrayList<Contact> contacts = gson.fromJson(chatMessage.getContent(), new TypeToken<ArrayList<Contact>>() {
    }.getType());
    if (cache) {
        // messageDatabaseHelper.saveContacts(contacts, getExpireAmount());
        dataSource.saveContactsResultFromServer(contacts);
    }
    resultContact.setContacts(contacts);
    resultContact.setContentCount(chatMessage.getContentCount());
    resultContact.setHasNext(contacts.size() + callback.getOffset() < chatMessage.getContentCount());
    resultContact.setNextOffset(callback.getOffset() + contacts.size());
    resultContact.setContentCount(chatMessage.getContentCount());
    outPutContact.setResult(resultContact);
    outPutContact.setErrorMessage("");
    outPutContact.setUniqueId(chatMessage.getUniqueId());
    return outPutContact;
}
Also used : ResultContact(com.fanap.podchat.model.ResultContact) TypeToken(com.google.gson.reflect.TypeToken) ChatResponse(com.fanap.podchat.model.ChatResponse) RequestAddContact(com.fanap.podchat.requestobject.RequestAddContact) ResultRemoveContact(com.fanap.podchat.model.ResultRemoveContact) ResultAddContact(com.fanap.podchat.model.ResultAddContact) UpdateContact(com.fanap.podchat.mainmodel.UpdateContact) RequestGetContact(com.fanap.podchat.requestobject.RequestGetContact) RequestUpdateContact(com.fanap.podchat.requestobject.RequestUpdateContact) RequestSearchContact(com.fanap.podchat.mainmodel.RequestSearchContact) Contact(com.fanap.podchat.mainmodel.Contact) ResultContact(com.fanap.podchat.model.ResultContact) RequestRemoveContact(com.fanap.podchat.requestobject.RequestRemoveContact) BlockedContact(com.fanap.podchat.mainmodel.BlockedContact) PhoneContact(com.fanap.podchat.cachemodel.PhoneContact) ResultUpdateContact(com.fanap.podchat.model.ResultUpdateContact) NonNull(android.support.annotation.NonNull)

Example 5 with ResultContact

use of com.fanap.podchat.model.ResultContact in project pod-chat-android-sdk by FanapSoft.

the class CallPresenter method onGetContacts.

@Override
public void onGetContacts(String content, ChatResponse<ResultContact> outPutContact) {
    super.onGetContacts(content, outPutContact);
    ArrayList<ContactsWrapper> contactsWrappers = new ArrayList<>();
    for (Contact c : outPutContact.getResult().getContacts()) {
        ContactsWrapper contactsWrapper = new ContactsWrapper(c);
        contactsWrappers.add(contactsWrapper);
    }
    ContactsFragment fragment = new ContactsFragment();
    Bundle v = new Bundle();
    v.putParcelableArrayList("CONTACTS", contactsWrappers);
    fragment.setArguments(v);
    if (!outPutContact.isCache())
        view.showContactsFragment(fragment);
    else
        view.updateContactsFragment(contactsWrappers);
}
Also used : Bundle(android.os.Bundle) ArrayList(java.util.ArrayList) ContactsWrapper(com.fanap.podchat.call.contacts.ContactsWrapper) ContactsFragment(com.fanap.podchat.call.contacts.ContactsFragment) ResultContact(com.fanap.podchat.model.ResultContact) ResultAddContact(com.fanap.podchat.model.ResultAddContact) RequestGetContact(com.fanap.podchat.requestobject.RequestGetContact) Contact(com.fanap.podchat.mainmodel.Contact)

Aggregations

ResultContact (com.fanap.podchat.model.ResultContact)8 RequestGetContact (com.fanap.podchat.requestobject.RequestGetContact)6 ChatListener (com.fanap.podchat.chat.ChatListener)4 Contact (com.fanap.podchat.mainmodel.Contact)3 ChatResponse (com.fanap.podchat.model.ChatResponse)3 NonNull (android.support.annotation.NonNull)2 BlockedContact (com.fanap.podchat.mainmodel.BlockedContact)2 RequestSearchContact (com.fanap.podchat.mainmodel.RequestSearchContact)2 ResultAddContact (com.fanap.podchat.model.ResultAddContact)2 ArrayList (java.util.ArrayList)2 SimpleSQLiteQuery (android.arch.persistence.db.SimpleSQLiteQuery)1 Bundle (android.os.Bundle)1 LargeTest (android.support.test.filters.LargeTest)1 CacheBlockedContact (com.fanap.podchat.cachemodel.CacheBlockedContact)1 CacheContact (com.fanap.podchat.cachemodel.CacheContact)1 PhoneContact (com.fanap.podchat.cachemodel.PhoneContact)1 ContactsFragment (com.fanap.podchat.call.contacts.ContactsFragment)1 ContactsWrapper (com.fanap.podchat.call.contacts.ContactsWrapper)1 UpdateContact (com.fanap.podchat.mainmodel.UpdateContact)1 ResultRemoveContact (com.fanap.podchat.model.ResultRemoveContact)1