use of com.fanap.podchat.model.ChatResponse in project pod-chat-android-sdk by FanapSoft.
the class MessagesCacheTest method populateThreadsListFromServerOnly.
// requests for list of threads from server
public void populateThreadsListFromServerOnly() {
chatListeners = new ChatListener() {
@Override
public void onGetThread(String content, ChatResponse<ResultThreads> response) {
if (!response.isCache()) {
System.out.println("Received List: " + content);
threads.addAll(response.getResult().getThreads().stream().filter(thread -> thread.getTitle() != null && thread.getId() > 0 && !thread.isClosed() && thread.getLastMessageVO() != null).collect(Collectors.toList()));
chat.removeListener(chatListeners);
resumeProcess();
}
}
};
chat.setListener(chatListeners);
RequestThread requestThread = new RequestThread.Builder().count(25).withNoCache().build();
presenter.getThreads(requestThread, null);
pauseProcess();
System.out.println("Received List: " + threads.size());
}
use of com.fanap.podchat.model.ChatResponse in project pod-chat-android-sdk by FanapSoft.
the class MessagesCacheTest method populateMessagesFromServer.
public void populateMessagesFromServer() {
populateThreadsListFromServerOnly();
assert threads.size() > 0;
Thread thread = threads.get(0);
chatListeners = new ChatListener() {
@Override
public void onGetHistory(String content, ChatResponse<ResultHistory> history) {
if (!history.isCache()) {
System.out.println("Received Message List Server: " + content);
threadMessagesList.addAll(history.getResult().getHistory().stream().filter(messageVO -> messageVO.getMessage() != null).collect(Collectors.toList()));
chat.removeListener(chatListeners);
resumeProcess();
}
}
};
chat.addListener(chatListeners);
RequestGetHistory requestGetHistory = new RequestGetHistory.Builder(thread.getId()).withNoCache().build();
chat.getHistory(requestGetHistory, null);
pauseProcess();
}
use of com.fanap.podchat.model.ChatResponse in project pod-chat-android-sdk by FanapSoft.
the class MentionCacheTest method populateMentionListFromServer.
public void populateMentionListFromServer(long threadId) {
chatListeners = new ChatListener() {
@Override
public void onGetMentionList(ChatResponse<ResultHistory> response) {
if (!response.isCache()) {
System.out.println("Received Mention Message List Server: " + response.getJson());
threadMentionMessagesListInServer.addAll(response.getResult().getHistory().stream().filter(messageVO -> messageVO.getMessage() != null).collect(Collectors.toList()));
chat.removeListener(chatListeners);
resumeProcess();
}
}
};
chat.setListener(chatListeners);
RequestGetMentionList req = new RequestGetMentionList.Builder(threadId).offset(0).count(25).build();
presenter.getMentionList(req);
pauseProcess();
System.out.println("Received Mention Message List Server: " + threadMentionMessagesListInServer.size());
}
use of com.fanap.podchat.model.ChatResponse in project pod-chat-android-sdk by FanapSoft.
the class HashTagCacheTest method populateHashTagListFromServer.
public void populateHashTagListFromServer(long threadId) {
threadHashTagMessagesListInServer.clear();
chatListeners = new ChatListener() {
@Override
public void onGetHashTagList(ChatResponse<ResultHistory> response) {
if (!response.isCache()) {
System.out.println("Received HashTag Message List Server: " + response.getJson());
threadHashTagMessagesListInServer.addAll(response.getResult().getHistory().stream().filter(messageVO -> messageVO.getMessage() != null).collect(Collectors.toList()));
chat.removeListener(chatListeners);
resumeProcess();
}
}
};
chat.setListener(chatListeners);
RequestGetHashTagList request = new RequestGetHashTagList.Builder(threadId).offset(0).count(25).setHashtag("test").build();
presenter.getHashTagList(request, null);
pauseProcess();
System.out.println("Received HashTag Message List Server: " + threadHashTagMessagesListInServer.size());
}
use of com.fanap.podchat.model.ChatResponse in project pod-chat-android-sdk by FanapSoft.
the class HashTagCacheTest method populateHashTagListFromCache.
public void populateHashTagListFromCache(long threadId) {
threadHashTagMessagesListInCache.clear();
chatListeners = new ChatListener() {
@Override
public void onGetHashTagList(ChatResponse<ResultHistory> response) {
if (response.isCache()) {
System.out.println("Received HashTag Message List Server: " + response.getJson());
threadHashTagMessagesListInCache.addAll(response.getResult().getHistory().stream().filter(messageVO -> messageVO.getMessage() != null).collect(Collectors.toList()));
chat.removeListener(chatListeners);
resumeProcess();
} else {
Assert.assertEquals(5, 10);
resumeProcess();
}
}
};
chat.setListener(chatListeners);
RequestGetHashTagList request = new RequestGetHashTagList.Builder(threadId).offset(0).count(25).setHashtag("test").build();
presenter.getHashTagList(request, null);
pauseProcess();
System.out.println("Received HashTag Message List Server: " + threadHashTagMessagesListInCache.size());
}
Aggregations