public void addMessageToHistory( Contact contact, Message message, String from, boolean isSystemNotice) { addText( Chat.buildMessage( contact, message, from, isSystemNotice, Chat.isHighlight(message.getProcessedText(), contact.getMyName()))); }
public synchronized boolean hasLastMessage(Chat chat, Message message) { Contact contact = chat.getContact(); boolean hasMessage = false; Cursor cursor = null; try { cursor = SawimApplication.getDatabaseHelper() .getReadableDatabase() .query( DatabaseHelper.TABLE_CHAT_HISTORY, null, DatabaseHelper.CONTACT_ID + " = ?", new String[] {uniqueUserId}, null, null, DatabaseHelper.DATE + " DESC", String.valueOf(60)); if (cursor.moveToLast()) { do { short rowData = cursor.getShort(cursor.getColumnIndex(DatabaseHelper.ROW_DATA)); MessData mess = Chat.buildMessage( contact, message, contact.isConference() ? message.getName() : chat.getFrom(message), false, Chat.isHighlight(message.getProcessedText(), contact.getMyName())); MessData messFromDataBase = buildMessage(chat, cursor); boolean isMessage = (rowData & MessData.PRESENCE) == 0 && (rowData & MessData.SERVICE) == 0 && (rowData & MessData.PROGRESS) == 0; if (isMessage) { hasMessage = hasMessage(mess, messFromDataBase); if (hasMessage) { return true; } } } while (cursor.moveToPrevious()); } } catch (Exception e) { DebugLog.panic(e); } finally { if (cursor != null) { cursor.close(); } } return hasMessage; }