Search in sources :

Example 1 with CacheForwardInfo

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);
        }
    }
}
Also used : CacheForwardInfo(com.fanap.podchat.cachemodel.CacheForwardInfo) CacheMessageVO(com.fanap.podchat.cachemodel.CacheMessageVO) CacheReplyInfoVO(com.fanap.podchat.cachemodel.CacheReplyInfoVO)

Example 2 with CacheForwardInfo

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);
    }
}
Also used : ChatProfileVO(com.fanap.podchat.chat.user.profile.ChatProfileVO) ThreadVo(com.fanap.podchat.cachemodel.ThreadVo) CacheThreadParticipant(com.fanap.podchat.cachemodel.CacheThreadParticipant) CacheParticipant(com.fanap.podchat.cachemodel.CacheParticipant) Participant(com.fanap.podchat.mainmodel.Participant) CacheCallParticipant(com.fanap.podchat.call.persist.CacheCallParticipant) CacheForwardInfo(com.fanap.podchat.cachemodel.CacheForwardInfo) ConversationSummery(com.fanap.podchat.model.ConversationSummery) ForwardInfo(com.fanap.podchat.mainmodel.ForwardInfo) CacheForwardInfo(com.fanap.podchat.cachemodel.CacheForwardInfo) CacheParticipant(com.fanap.podchat.cachemodel.CacheParticipant) CacheMessageVO(com.fanap.podchat.cachemodel.CacheMessageVO) ReplyInfoVO(com.fanap.podchat.model.ReplyInfoVO) CacheReplyInfoVO(com.fanap.podchat.cachemodel.CacheReplyInfoVO) CacheReplyInfoVO(com.fanap.podchat.cachemodel.CacheReplyInfoVO) CacheMessageVO(com.fanap.podchat.cachemodel.CacheMessageVO) PinMessageVO(com.fanap.podchat.mainmodel.PinMessageVO) MessageVO(com.fanap.podchat.mainmodel.MessageVO) GapMessageVO(com.fanap.podchat.cachemodel.GapMessageVO) Thread(com.fanap.podchat.mainmodel.Thread)

Example 3 with CacheForwardInfo

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;
}
Also used : CacheForwardInfo(com.fanap.podchat.cachemodel.CacheForwardInfo)

Aggregations

CacheForwardInfo (com.fanap.podchat.cachemodel.CacheForwardInfo)3 CacheMessageVO (com.fanap.podchat.cachemodel.CacheMessageVO)2 CacheReplyInfoVO (com.fanap.podchat.cachemodel.CacheReplyInfoVO)2 CacheParticipant (com.fanap.podchat.cachemodel.CacheParticipant)1 CacheThreadParticipant (com.fanap.podchat.cachemodel.CacheThreadParticipant)1 GapMessageVO (com.fanap.podchat.cachemodel.GapMessageVO)1 ThreadVo (com.fanap.podchat.cachemodel.ThreadVo)1 CacheCallParticipant (com.fanap.podchat.call.persist.CacheCallParticipant)1 ChatProfileVO (com.fanap.podchat.chat.user.profile.ChatProfileVO)1 ForwardInfo (com.fanap.podchat.mainmodel.ForwardInfo)1 MessageVO (com.fanap.podchat.mainmodel.MessageVO)1 Participant (com.fanap.podchat.mainmodel.Participant)1 PinMessageVO (com.fanap.podchat.mainmodel.PinMessageVO)1 Thread (com.fanap.podchat.mainmodel.Thread)1 ConversationSummery (com.fanap.podchat.model.ConversationSummery)1 ReplyInfoVO (com.fanap.podchat.model.ReplyInfoVO)1