use of com.fanap.podchat.mainmodel.MessageVO in project pod-chat-android-sdk by FanapSoft.
the class DbTest method updateMessagesWithMessageId.
@Test
public void updateMessagesWithMessageId() {
long threadId = 2;
Callback callback = new Callback();
List<MessageVO> messageVOS = new ArrayList<>();
callback.setMessageId(6181);
callback.setOrder("asc");
messageDatabaseHelper.updateGetHistoryResponse(callback, messageVOS, threadId, null);
}
use of com.fanap.podchat.mainmodel.MessageVO in project pod-chat-android-sdk by FanapSoft.
the class DbTest method justFirstMsgIdset2.
// first message id conditional 2
@Test
public void justFirstMsgIdset2() {
Callback callback = new Callback();
long threadId = 2;
List<MessageVO> messageVOS = new ArrayList<>();
// MessageVO messageVO = new MessageVO(
// 5653,
// false,
// false,
// false,
// false,
// false,
// "91efe7da-547f-4c5f-c34b-0442951ffbbc",
// 0,
// 5652,
// "",
// null,
// 13354321,
// 321000000,
// "",
// null,
// null,
// null,
// null
// );
callback.setOffset(0);
callback.setCount(2);
callback.setOrder("asc");
callback.setFirstMessageId(9236);
messageDatabaseHelper.updateGetHistoryResponse(callback, null, threadId, null);
}
use of com.fanap.podchat.mainmodel.MessageVO in project pod-chat-android-sdk by FanapSoft.
the class DbTest method updateCacheFAndLConditional3.
// first messsage and last message
// Conditional 3
// cache siz more than one but server size is more than 1
@Test
public void updateCacheFAndLConditional3() {
long threadId = 2;
Callback callback = new Callback();
List<MessageVO> messageVOS = new ArrayList<>();
// MessageVO messageVO = new MessageVO(
// 5653,
// false,
// false,
// false,
// false,
// false,
// "91efe7da-547f-4c5f-c34b-0442951ffbbc",
// 0,
// 5652,
// "",
// null,
// 13354321,
// 321000000,
// "",
// null,
// null,
// null,
// null
// );
// messageVOS.add(messageVO);
callback.setOffset(0);
callback.setCount(50);
callback.setOrder("asc");
callback.setFirstMessageId(5652);
callback.setLastMessageId(5653);
messageDatabaseHelper.updateGetHistoryResponse(callback, messageVOS, threadId, null);
}
use of com.fanap.podchat.mainmodel.MessageVO in project pod-chat-android-sdk by FanapSoft.
the class MessageDatabaseHelper method getHistories.
@NonNull
public List<MessageVO> getHistories(@NonNull History history, long threadId) {
List<MessageVO> messageVOS = new ArrayList<>();
List<CacheMessageVO> cacheMessageVOS;
long fromTime = history.getFromTime();
long fromTimeNanos = history.getFromTimeNanos();
long toTime = history.getToTime();
long toTimeNanos = history.getToTimeNanos();
long messageId = history.getId();
long offset = history.getOffset();
long count = history.getCount();
String query = history.getQuery();
String order = history.getOrder();
offset = offset >= 0 ? offset : 0;
count = count > 0 ? count : 50;
if (Util.isNullOrEmpty(order)) {
order = "desc";
}
String rawQuery = "SELECT * FROM CacheMessageVO WHERE threadVoId =" + threadId;
rawQuery = addMessageIdIfExist(messageId, rawQuery);
rawQuery = addFromTimeIfExist(fromTime, fromTimeNanos, rawQuery);
rawQuery = addToTimeIfExist(toTime, toTimeNanos, rawQuery);
rawQuery = addQueryIfExist(query, rawQuery);
rawQuery = addOrderAndLimitAndOffset(offset, count, order, rawQuery);
SupportSQLiteQuery sqLiteQuery = new SimpleSQLiteQuery(rawQuery);
cacheMessageVOS = messageDao.getRawHistory(sqLiteQuery);
prepareMessageVOs(messageVOS, cacheMessageVOS);
return messageVOS;
}
use of com.fanap.podchat.mainmodel.MessageVO 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);
}
}
Aggregations