public void loadMessages() { ArrayList<Message> messages = DatabaseHelper.getInstance(mContext) .getMessage( true, DatabaseHelper.ROOM_ID + "='" + mTalkee.getRoomId() + "' or (" + DatabaseHelper.SENDER_ROOM_ID + "='" + mTalkee.getRoomId() + "' and " + DatabaseHelper.ROOM_ID + "='" + mMe.getRoomId() + "')"); mMessages.addAll(messages); mAdapter.notifyDataSetChanged(); mMessageInput.setText(""); try { seenMessagesOnServer(messages, true); } catch (JSONException e) { e.printStackTrace(); } }
public void addMessage(Message message) { // add message to list mMessages.add(message); mAdapter.notifyDataSetChanged(); mMessageInput.setText(""); if (message.getSender().getId().equals(mMe.getId())) { DatabaseHelper.getInstance(mContext).InsertMessageNoUpdate(message); } }