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);
}
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());
}
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");
}
}
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;
}
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);
}
Aggregations