use of com.fanap.podchat.cachemodel.CacheForwardInfo in project pod-chat-android-sdk by FanapSoft.
the class MessageDatabaseHelper method updateThreadLastMessage.
private void updateThreadLastMessage(Thread thread, ThreadVo threadVo) {
CacheMessageVO cacheMessageVO = null;
CacheReplyInfoVO cacheReplyInfoVO;
CacheForwardInfo cacheForwardInfo;
if (thread.getLastMessageVO() != null)
cacheMessageVO = insertLastMessage(thread, threadVo);
if (cacheMessageVO == null)
return;
if (threadVo.getLastMessageVO().getParticipant() != null) {
insertParticipant(cacheMessageVO, threadVo);
}
if (threadVo.getLastMessageVO().getReplyInfoVO() != null) {
cacheReplyInfoVO = insertReplyInfo(cacheMessageVO, threadVo);
if (threadVo.getLastMessageVO().getReplyInfoVO().getParticipant() != null) {
insertReplyParticipant(cacheReplyInfoVO, threadVo);
}
}
if (threadVo.getLastMessageVO().getForwardInfo() != null) {
cacheForwardInfo = insertForwardInfo(cacheMessageVO, threadVo);
if (threadVo.getLastMessageVO().getForwardInfo().getParticipant() != null) {
insertForwardInfo(cacheForwardInfo, threadVo);
}
if (threadVo.getLastMessageVO().getForwardInfo().getConversation() != null) {
insertConversationSummary(cacheForwardInfo, threadVo);
}
}
}
use of com.fanap.podchat.cachemodel.CacheForwardInfo in project pod-chat-android-sdk by FanapSoft.
the class MessageDatabaseHelper method prepareMessageVOs.
private void prepareMessageVOs(List<MessageVO> messageVOS, List<CacheMessageVO> cacheMessageVOS) {
for (CacheMessageVO cacheMessageVO : cacheMessageVOS) {
Participant participant = null;
ReplyInfoVO replyInfoVO = null;
ForwardInfo forwardInfo = null;
ConversationSummery conversationSummery = null;
if (cacheMessageVO.getForwardInfoId() != null) {
cacheMessageVO.setForwardInfo(messageDao.getForwardInfo(cacheMessageVO.getForwardInfoId()));
}
if (cacheMessageVO.getParticipantId() != null) {
CacheParticipant cacheParticipant = messageDao.getParticipant(cacheMessageVO.getParticipantId());
if (cacheParticipant != null) {
ChatProfileVO profileVO = messageDao.getChatProfileVOById(cacheParticipant.getId());
cacheParticipant.setChatProfileVO(profileVO);
participant = cacheToParticipantMapper(cacheParticipant, null, null);
} else {
if (cacheMessageVO.getConversationId() > 0)
messageDao.deleteParticipant(cacheMessageVO.getConversationId(), cacheMessageVO.getParticipantId());
}
}
ThreadVo thread = messageDao.getThreadById(cacheMessageVO.getConversationId());
cacheMessageVO.setConversation(thread);
if (cacheMessageVO.getReplyInfoVOId() != null) {
CacheReplyInfoVO cacheReplyInfoVO = messageDao.getReplyInfo(cacheMessageVO.getReplyInfoVOId());
if (cacheReplyInfoVO != null) {
replyInfoVO = new ReplyInfoVO(cacheReplyInfoVO.getRepliedToMessageId(), cacheReplyInfoVO.getMessageType(), cacheReplyInfoVO.isDeleted(), cacheReplyInfoVO.getRepliedToMessage(), cacheReplyInfoVO.getSystemMetadata(), cacheReplyInfoVO.getMetadata(), cacheReplyInfoVO.getMessage(), cacheReplyInfoVO.getRepliedToMessageTime(), cacheReplyInfoVO.getRepliedToMessageNanos());
if (cacheReplyInfoVO.getParticipantId() > 0) {
CacheParticipant cacheParticipant = messageDao.getParticipant(cacheReplyInfoVO.getParticipantId());
if (cacheParticipant != null) {
Participant replyParticipant = cacheToParticipantMapper(cacheParticipant, false, null);
replyInfoVO.setParticipant(replyParticipant);
}
}
}
}
if (cacheMessageVO.getForwardInfo() != null) {
CacheForwardInfo cacheForwardInfo = messageDao.getForwardInfo(cacheMessageVO.getForwardInfoId());
if (cacheForwardInfo != null) {
if (cacheForwardInfo.getParticipantId() != null) {
CacheParticipant cacheParticipant = messageDao.getParticipant(cacheForwardInfo.getParticipantId());
if (cacheParticipant != null) {
participant = cacheToParticipantMapper(cacheParticipant, null, null);
}
}
if (Util.isNullOrEmpty(cacheForwardInfo.getConversationId())) {
// todo check it again
conversationSummery = messageDao.getConversationSummery(cacheForwardInfo.getConversationId());
}
forwardInfo = new ForwardInfo(participant, conversationSummery);
}
}
Thread msgThread = threadVoToThreadMapper(cacheMessageVO.getConversation(), null);
MessageVO messageVO = cacheMessageVoToMessageVoMapper(participant, replyInfoVO, forwardInfo, cacheMessageVO);
messageVO.setConversation(msgThread);
messageVOS.add(messageVO);
}
}
use of com.fanap.podchat.cachemodel.CacheForwardInfo in project pod-chat-android-sdk by FanapSoft.
the class MessageDatabaseHelper method insertForwardInfo.
private CacheForwardInfo insertForwardInfo(CacheMessageVO cacheMessageVO, ThreadVo threadVo) {
CacheForwardInfo cacheForwardInfo;
cacheForwardInfo = threadVo.getLastMessageVO().getForwardInfo();
cacheForwardInfo.setId(threadVo.getLastMessageVO().getId());
messageDao.insertForwardInfo(cacheForwardInfo);
cacheMessageVO.setForwardInfoId(threadVo.getLastMessageVO().getId());
messageDao.insertLastMessageVO(cacheMessageVO);
return cacheForwardInfo;
}
Aggregations