use of com.fanap.podchat.model.ChatResponse in project pod-chat-android-sdk by FanapSoft.
the class ChatCore method reformatThreadParticipants.
private ChatResponse<ResultParticipant> reformatThreadParticipants(Callback callback, ChatMessage chatMessage) {
ArrayList<Participant> participants = new ArrayList<>();
if (!Util.isNullOrEmpty(chatMessage.getContent())) {
try {
participants = gson.fromJson(chatMessage.getContent(), new TypeToken<ArrayList<Participant>>() {
}.getType());
} catch (Exception e) {
showErrorLog(e.getMessage());
onUnknownException(chatMessage.getUniqueId(), e);
}
}
if (cache) {
List<CacheParticipant> cacheParticipants = new ArrayList<>();
if (!Util.isNullOrEmpty(chatMessage.getContent())) {
try {
cacheParticipants = gson.fromJson(chatMessage.getContent(), new TypeToken<ArrayList<CacheParticipant>>() {
}.getType());
} catch (JsonSyntaxException e) {
showErrorLog(e.getMessage());
onUnknownException(chatMessage.getUniqueId(), e);
}
}
if (!cacheParticipants.isEmpty())
messageDatabaseHelper.saveParticipants(cacheParticipants, chatMessage.getSubjectId(), getExpireAmount());
}
ChatResponse<ResultParticipant> outPutParticipant = new ChatResponse<>();
outPutParticipant.setErrorCode(0);
outPutParticipant.setErrorMessage("");
outPutParticipant.setHasError(false);
outPutParticipant.setUniqueId(chatMessage.getUniqueId());
outPutParticipant.setSubjectId(chatMessage.getSubjectId());
ResultParticipant resultParticipant = new ResultParticipant();
resultParticipant.setContentCount(chatMessage.getContentCount());
resultParticipant.setThreadId(chatMessage.getSubjectId());
if (callback != null) {
resultParticipant.setHasNext(participants.size() + callback.getOffset() < chatMessage.getContentCount());
resultParticipant.setNextOffset(callback.getOffset() + participants.size());
}
resultParticipant.setParticipants(participants);
outPutParticipant.setResult(resultParticipant);
return outPutParticipant;
}
use of com.fanap.podchat.model.ChatResponse in project pod-chat-android-sdk by FanapSoft.
the class ChatCore method reformatNotSeenDuration.
private ChatResponse<ResultNotSeenDuration> reformatNotSeenDuration(ChatMessage chatMessage, Callback callback) {
ChatResponse<ResultNotSeenDuration> response = new ChatResponse<>();
Map<String, Long> idNotSeenPairs = new HashMap<>();
JsonParser parser = new JsonParser();
JsonObject jsonObject;
try {
jsonObject = parser.parse(chatMessage.getContent()).getAsJsonObject();
} catch (Exception e) {
captureError(e.getMessage(), ChatConstant.ERROR_CODE_UNKNOWN_EXCEPTION, chatMessage.getUniqueId(), e);
return null;
}
for (String key : jsonObject.keySet()) {
idNotSeenPairs.put(key, jsonObject.get(key).getAsLong());
}
ResultNotSeenDuration resultNotSeenDuration = new ResultNotSeenDuration();
resultNotSeenDuration.setIdNotSeenPair(idNotSeenPairs);
response.setResult(resultNotSeenDuration);
return response;
}
use of com.fanap.podchat.model.ChatResponse in project pod-chat-android-sdk by FanapSoft.
the class ThreadManager method handleChangeThreadType.
public static ChatResponse<Thread> handleChangeThreadType(ChatMessage chatMessage) {
ChatResponse<Thread> response = new ChatResponse<>();
Thread thread = App.getGson().fromJson(chatMessage.getContent(), new TypeToken<Thread>() {
}.getType());
response.setResult(thread);
response.setUniqueId(chatMessage.getUniqueId());
response.setCache(false);
return response;
}
use of com.fanap.podchat.model.ChatResponse in project pod-chat-android-sdk by FanapSoft.
the class Mention method getMentionListResponse.
public static ChatResponse<ResultHistory> getMentionListResponse(ChatMessage chatMessage) {
List<MessageVO> messageVOS = getMessageVOSFromChatMessage(chatMessage);
ResultHistory resultHistory = new ResultHistory();
resultHistory.setContentCount(chatMessage.getContentCount());
resultHistory.setHistory(messageVOS);
ChatResponse<ResultHistory> finalResponse = new ChatResponse<>();
finalResponse.setResult(resultHistory);
finalResponse.setUniqueId(chatMessage.getUniqueId());
finalResponse.setSubjectId(chatMessage.getSubjectId());
return finalResponse;
}
use of com.fanap.podchat.model.ChatResponse in project pod-chat-android-sdk by FanapSoft.
the class MessageManager method prepareNewMessageResponse.
public static ChatResponse<ResultNewMessage> prepareNewMessageResponse(MessageVO newMessage, long threadId, String uniqueId) {
ChatResponse<ResultNewMessage> chatResponse = new ChatResponse<>();
ResultNewMessage editMessage = new ResultNewMessage();
editMessage.setMessageVO(newMessage);
editMessage.setThreadId(threadId);
chatResponse.setResult(editMessage);
chatResponse.setUniqueId(uniqueId);
chatResponse.setSubjectId(threadId);
return chatResponse;
}
Aggregations