Search in sources :

Example 1 with CacheTagVo

use of com.fanap.podchat.cachemodel.CacheTagVo in project pod-chat-android-sdk by FanapSoft.

the class MessageDatabaseHelper method prepareTagList.

private List<TagVo> prepareTagList() {
    List<CacheTagVo> tags = messageDao.getCacheTagVos();
    List<TagVo> tagVos = new ArrayList<>();
    for (CacheTagVo item : tags) {
        TagVo tag = CacheTagVoToTagVoMapper(item);
        long allUnreadCount = 0;
        List<CacheTagParticipantVO> cacheTagParticipants = messageDao.getCacheTagParticipantVosByTagId(item.getTagId());
        List<TagParticipantVO> tagParticipants = new ArrayList<>();
        for (CacheTagParticipantVO cacheTagParticipantVO : cacheTagParticipants) {
            TagParticipantVO cache = cacheTagParticipantVOToTagParticipantVOMapper(cacheTagParticipantVO);
            if (messageDao.getThreadById(cacheTagParticipantVO.getThreadId()) != null) {
                Thread thread = threadVoToThreadMapper(messageDao.getThreadById(cacheTagParticipantVO.getThreadId()), null);
                cache.setConversationVO(thread);
                // TODO it should be save in db. can save it when save tags on db
                if (thread.getUnreadCount() > 0)
                    allUnreadCount = allUnreadCount + thread.getUnreadCount();
            }
            tagParticipants.add(cache);
        }
        tag.setTagParticipants(tagParticipants);
        tag.setAllUnreadCount(allUnreadCount);
        tagVos.add(tag);
    }
    return tagVos;
}
Also used : CacheTagParticipantVO(com.fanap.podchat.cachemodel.CacheTagParticipantVO) CacheTagVo(com.fanap.podchat.cachemodel.CacheTagVo) ArrayList(java.util.ArrayList) CacheTagParticipantVO(com.fanap.podchat.cachemodel.CacheTagParticipantVO) TagParticipantVO(com.fanap.podchat.model.TagParticipantVO) TagVo(com.fanap.podchat.model.TagVo) CacheTagVo(com.fanap.podchat.cachemodel.CacheTagVo) Thread(com.fanap.podchat.mainmodel.Thread)

Example 2 with CacheTagVo

use of com.fanap.podchat.cachemodel.CacheTagVo in project pod-chat-android-sdk by FanapSoft.

the class MessageDatabaseHelper method updateCacheTagVo.

public void updateCacheTagVo(TagVo tag) {
    CacheTagVo cacheFile = new CacheTagVo();
    cacheFile.setTagId(tag.getTagId());
    cacheFile.setActive(tag.isActive());
    cacheFile.setName(tag.getTagName());
    if (tag.getTagParticipants() != null && tag.getTagParticipants().size() > 0)
        updateCacheTagParticipantVos(tag.getTagParticipants(), tag.getTagId());
    messageDao.insertCacheTagVo(cacheFile);
}
Also used : CacheTagVo(com.fanap.podchat.cachemodel.CacheTagVo)

Aggregations

CacheTagVo (com.fanap.podchat.cachemodel.CacheTagVo)2 CacheTagParticipantVO (com.fanap.podchat.cachemodel.CacheTagParticipantVO)1 Thread (com.fanap.podchat.mainmodel.Thread)1 TagParticipantVO (com.fanap.podchat.model.TagParticipantVO)1 TagVo (com.fanap.podchat.model.TagVo)1 ArrayList (java.util.ArrayList)1