use of com.fanap.podchat.cachemodel.CacheTagParticipantVO 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;
}
use of com.fanap.podchat.cachemodel.CacheTagParticipantVO in project pod-chat-android-sdk by FanapSoft.
the class MessageDatabaseHelper method getTagParticipantsVos.
public Observable<List<TagParticipantVO>> getTagParticipantsVos(long tagId) {
return Observable.create(emitter -> {
try {
List<CacheTagParticipantVO> tagParticipants = messageDao.getCacheTagParticipantVosByTagId(tagId);
List<TagParticipantVO> cacheTagParticipants = new ArrayList<>();
for (CacheTagParticipantVO item : tagParticipants) {
TagParticipantVO cache = cacheTagParticipantVOToTagParticipantVOMapper(item);
if (messageDao.getThreadById(item.getThreadId()) != null) {
Thread thread = threadVoToThreadMapper(messageDao.getThreadById(item.getThreadId()), null);
cache.setConversationVO(thread);
}
cacheTagParticipants.add(cache);
}
emitter.onNext(cacheTagParticipants);
emitter.onCompleted();
} catch (Exception e) {
emitter.onError(e);
}
});
}
use of com.fanap.podchat.cachemodel.CacheTagParticipantVO in project pod-chat-android-sdk by FanapSoft.
the class MessageDatabaseHelper method updateCacheTagParticipantVos.
public void updateCacheTagParticipantVos(List<TagParticipantVO> tagParticipantVOS, long tagId) {
worker(() -> {
List<CacheTagParticipantVO> tagVos = new ArrayList<>();
for (TagParticipantVO item : tagParticipantVOS) {
CacheTagParticipantVO cache = new CacheTagParticipantVO();
cache.setThreadId(item.getThreadId());
cache.setActive(item.isActive());
cache.setTagId(tagId);
cache.setId(item.getId());
tagVos.add(cache);
if (item.getConversationVO() != null)
saveNewThread(item.getConversationVO());
}
messageDao.insertCacheTagParticipantVos(tagVos);
});
}
Aggregations