use of com.fanap.podchat.mainmodel.Thread in project pod-chat-android-sdk by FanapSoft.
the class ChatCore method handleAddParticipant.
private void handleAddParticipant(ChatMessage chatMessage, String messageUniqueId) {
Thread thread = gson.fromJson(chatMessage.getContent(), Thread.class);
if (cache) {
ThreadVo threadVo = gson.fromJson(chatMessage.getContent(), ThreadVo.class);
List<CacheParticipant> cacheParticipants = threadVo.getParticipants();
if (!Util.isNullOrEmpty(cacheParticipants))
messageDatabaseHelper.saveParticipants(cacheParticipants, thread.getId(), getExpireAmount());
}
ChatResponse<ResultAddParticipant> chatResponse = ParticipantsManager.prepareAddParticipantResponse(chatMessage, thread);
String jsonAddParticipant = gson.toJson(chatResponse);
if (sentryResponseLog) {
showLog("RECEIVE_ADD_PARTICIPANT", jsonAddParticipant);
} else {
showLog("RECEIVE_ADD_PARTICIPANT");
}
messageCallbacks.remove(messageUniqueId);
listenerManager.callOnThreadAddParticipant(jsonAddParticipant, chatResponse);
}
use of com.fanap.podchat.mainmodel.Thread in project pod-chat-android-sdk by FanapSoft.
the class ChatCore method handleThreadInfoUpdated.
private void handleThreadInfoUpdated(ChatMessage chatMessage) {
ResultThread resultThread = new ResultThread();
Thread thread = gson.fromJson(chatMessage.getContent(), Thread.class);
resultThread.setThread(thread);
ChatResponse<ResultThread> chatResponse = new ChatResponse<>();
chatResponse.setResult(resultThread);
chatResponse.setUniqueId(chatMessage.getUniqueId());
if (sentryResponseLog) {
showLog("THREAD_INFO_UPDATED", chatMessage.getContent());
} else {
showLog("THREAD_INFO_UPDATED");
}
if (cache) {
dataSource.saveThreadResultFromServer(resultThread.getThread());
}
listenerManager.callOnThreadInfoUpdated(chatMessage.getContent(), chatResponse);
}
use of com.fanap.podchat.mainmodel.Thread in project pod-chat-android-sdk by FanapSoft.
the class ChatCore method reformatCreateThread.
private ChatResponse<ResultThread> reformatCreateThread(ChatMessage chatMessage) {
ChatResponse<ResultThread> chatResponse = new ChatResponse<>();
chatResponse.setUniqueId(chatMessage.getUniqueId());
ResultThread resultThread = new ResultThread();
Thread thread = gson.fromJson(chatMessage.getContent(), Thread.class);
resultThread.setThread(thread);
chatResponse.setResult(resultThread);
resultThread.setThread(thread);
return chatResponse;
}
use of com.fanap.podchat.mainmodel.Thread in project pod-chat-android-sdk by FanapSoft.
the class PublicThread method handleJoinThread.
public static ChatResponse<ResultJoinPublicThread> handleJoinThread(ChatMessage chatMessage) {
Thread thread = new Thread();
try {
thread = App.getGson().fromJson(chatMessage.getContent(), Thread.class);
} catch (JsonSyntaxException e) {
e.printStackTrace();
}
ResultJoinPublicThread result = new ResultJoinPublicThread();
result.setThread(thread);
ChatResponse<ResultJoinPublicThread> response = new ChatResponse<>();
response.setResult(result);
return response;
}
use of com.fanap.podchat.mainmodel.Thread in project pod-chat-android-sdk by FanapSoft.
the class AssistantCacheTest method populateParticipantList.
@Test
public void populateParticipantList() {
populateThreadsListFromServerOnly();
assert threads.size() > 0;
Thread thread = getValidGroupThread();
chatListeners = new ChatListener() {
@Override
public void onGetThreadParticipant(String content, ChatResponse<ResultParticipant> response) {
System.out.println("Received Participant, Cache: " + response.isCache() + " Content: " + content);
if (response.getResult().getParticipants().size() > 1) {
threadParticipant.addAll(response.getResult().getParticipants());
chat.removeListener(chatListeners);
resumeProcess();
} else {
threads.remove(thread);
Thread t2 = getValidGroupThread();
print("try again changing thread...");
RequestThreadParticipant request = new RequestThreadParticipant.Builder().threadId(t2.getId()).build();
chat.getThreadParticipants(request, null);
}
}
};
chat.addListener(chatListeners);
RequestThreadParticipant request = new RequestThreadParticipant.Builder().threadId(thread.getId()).build();
chat.getThreadParticipants(request, null);
pauseProcess();
}
Aggregations