use of com.fanap.podchat.cachemodel.CacheMessageVO in project pod-chat-android-sdk by FanapSoft.
the class MessageDatabaseHelper method deleteMessage.
public void deleteMessage(long id, long subjectId) {
// if this message is thread last message
// get previous message and then delete this
// then set previous message as last message
worker(() -> {
if (subjectId > 0) {
ThreadVo threadVo = messageDao.getThreadById(subjectId);
if (threadVo != null) {
long threadLastMessageId = threadVo.getLastMessageVOId();
if (threadLastMessageId == id && threadLastMessageId > 0) {
// this is last message
List<CacheMessageVO> cacheMessage = messageDao.getMessage(id);
if (!Util.isNullOrEmpty(cacheMessage)) {
long previousMessageId = cacheMessage.get(0).getPreviousId();
// Get previous message
List<CacheMessageVO> previousMessage = messageDao.getMessage(previousMessageId);
if (!Util.isNullOrEmpty(previousMessage)) {
String message = previousMessage.get(0).getMessage();
messageDao.updateThreadLastMessageVOId(subjectId, previousMessageId, message);
}
}
}
}
// delete from pinned message
PinMessageVO pinnedMessage = messageDao.getThreadPinnedMessage(subjectId);
if (pinnedMessage != null && pinnedMessage.getMessageId() == id) {
messageDao.deletePinnedMessageById(id);
}
}
messageDao.deleteMessage(id);
});
}
use of com.fanap.podchat.cachemodel.CacheMessageVO in project pod-chat-android-sdk by FanapSoft.
the class MessageDatabaseHelper method getHashTagList.
public void getHashTagList(RequestGetHashTagList request, FunctionalListener listener) {
worker(() -> {
List<MessageVO> messageVOS = new ArrayList<>();
List<CacheMessageVO> cacheMessageVOS = new ArrayList<>();
String condistion = "'%" + request.getHashtag() + "%'";
String rawQuery = "SELECT * FROM CacheMessageVO WHERE threadVoId = " + request.getThreadId() + " And hashtags LIKE " + condistion;
SupportSQLiteQuery sqLiteQuery = new SimpleSQLiteQuery(rawQuery);
cacheMessageVOS = messageDao.getRawHistory(sqLiteQuery);
String contentCountQuery = "SELECT count(*) FROM CacheMessageVO WHERE threadVoId = " + request.getThreadId() + " And hashtags LIKE " + condistion;
long contentCount = messageDao.getHistoryContentCount(new SimpleSQLiteQuery(contentCountQuery));
prepareMessageVOs(messageVOS, cacheMessageVOS);
if (messageVOS.size() > 0)
listener.onWorkDone(messageVOS, contentCount);
});
}
Aggregations