diff options
author | Daniel Gultsch <daniel.gultsch@rwth-aachen.de> | 2014-01-27 20:40:42 +0100 |
---|---|---|
committer | Daniel Gultsch <daniel.gultsch@rwth-aachen.de> | 2014-01-27 20:40:42 +0100 |
commit | 4f902d8210d50a586c7ece1bb7da2ab26fd18da5 (patch) | |
tree | b15d34a909443f79ac10d28f23eca19cf1c3301e /src/de/gultsch/chat/entities/Conversation.java | |
parent | 898b0ca8c485888e06e2b5b1c798eebce1a6dabc (diff) |
conversation archiveable. new conversation will find or restart old conversations
Diffstat (limited to '')
-rw-r--r-- | src/de/gultsch/chat/entities/Conversation.java | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/src/de/gultsch/chat/entities/Conversation.java b/src/de/gultsch/chat/entities/Conversation.java index 413e3d62..a00dd476 100644 --- a/src/de/gultsch/chat/entities/Conversation.java +++ b/src/de/gultsch/chat/entities/Conversation.java @@ -53,8 +53,31 @@ public class Conversation extends AbstractEntity { public List<Message> getMessages() { if (messages == null) this.messages = new ArrayList<Message>(); //prevent null pointer + + //populate with Conversation (this) + + for(Message msg : messages) { + msg.setConversation(this); + } + return messages; } + + public String getLatestMessage() { + if ((this.messages == null)||(this.messages.size()==0)) { + return null; + } else { + return this.messages.get(this.messages.size() - 1).getBody(); + } + } + + public long getLatestMessageDate() { + if ((this.messages == null)||(this.messages.size()==0)) { + return this.getCreated(); + } else { + return this.messages.get(this.messages.size() - 1).getTimeSent(); + } + } public void setMessages(List<Message> msgs) { this.messages = msgs; @@ -112,4 +135,8 @@ public class Conversation extends AbstractEntity { cursor.getLong(cursor.getColumnIndex(CREATED)), cursor.getInt(cursor.getColumnIndex(STATUS))); } + + public void setStatus(int status) { + this.status = status; + } } |