private static MessData buildMessage(Chat chat, Cursor cursor) { Contact contact = chat.getContact(); int sendingState = cursor.getInt(cursor.getColumnIndex(DatabaseHelper.SENDING_STATE)); boolean isIncoming = cursor.getInt(cursor.getColumnIndex(DatabaseHelper.INCOMING)) == 0; String from = cursor.getString(cursor.getColumnIndex(DatabaseHelper.AUTHOR)); String text = cursor.getString(cursor.getColumnIndex(DatabaseHelper.MESSAGE)); long date = cursor.getLong(cursor.getColumnIndex(DatabaseHelper.DATE)); short rowData = cursor.getShort(cursor.getColumnIndex(DatabaseHelper.ROW_DATA)); // String serverMsgId = cursor.getString(cursor.getColumnIndex(DatabaseHelper.SERVER_MSG_ID)); PlainMessage message; if (isIncoming) { message = new PlainMessage(from, chat.getProtocol(), date, text, true); } else { message = new PlainMessage(chat.getProtocol(), contact.getUserId(), date, text); } // message.setServerMsgId(serverMsgId); MessData messData; if (rowData == 0) { messData = Chat.buildMessage( contact, message, contact.isConference() ? from : chat.getFrom(message), false, isIncoming ? Chat.isHighlight(message.getProcessedText(), contact.getMyName()) : false); } else if ((rowData & MessData.ME) != 0 || (rowData & MessData.PRESENCE) != 0) { messData = new MessData(contact, message.getNewDate(), text, from, rowData); } else { messData = Chat.buildMessage( contact, message, contact.isConference() ? from : chat.getFrom(message), rowData, Chat.isHighlight(message.getProcessedText(), contact.getMyName())); } if (!message.isIncoming() && !messData.isMe()) { messData.setIconIndex((byte) sendingState); } return messData; }
public void addText(MessData md) { addText( md.getIconIndex(), md.isIncoming(), md.getNick(), md.getText().toString(), md.getTime(), md.getRowData(), md.getServerMsgId()); }
private static boolean hasMessage(MessData mess, MessData messFromDataBase) { return mess.getNick().equals(messFromDataBase.getNick()) && mess.getText().toString().equals(messFromDataBase.getText().toString()); }