aboutsummaryrefslogtreecommitdiffstats
path: root/src/main/java/eu/siacs/conversations/entities
diff options
context:
space:
mode:
authorDaniel Gultsch <daniel@gultsch.de>2016-06-09 14:50:13 +0200
committerChristian Schneppe <christian@pix-art.de>2016-06-10 23:04:36 +0200
commit1c143e91f8c98ff3bd1af23a81e3b5f91946137d (patch)
tree7786e44d9e6b648ccd8e85871fc9e060b4a9eee4 /src/main/java/eu/siacs/conversations/entities
parentb2b3f20c172ba59953c56f62e9c3c815fd6b9485 (diff)
catch conversations sort exception. not vital at this point
Diffstat (limited to 'src/main/java/eu/siacs/conversations/entities')
-rw-r--r--src/main/java/eu/siacs/conversations/entities/Conversation.java15
1 files changed, 14 insertions, 1 deletions
diff --git a/src/main/java/eu/siacs/conversations/entities/Conversation.java b/src/main/java/eu/siacs/conversations/entities/Conversation.java
index f10cd6780..77460ca9d 100644
--- a/src/main/java/eu/siacs/conversations/entities/Conversation.java
+++ b/src/main/java/eu/siacs/conversations/entities/Conversation.java
@@ -28,7 +28,7 @@ import eu.siacs.conversations.xmpp.jid.InvalidJidException;
import eu.siacs.conversations.xmpp.jid.Jid;
-public class Conversation extends AbstractEntity implements Blockable {
+public class Conversation extends AbstractEntity implements Blockable, Comparable<Conversation> {
public static final String TABLENAME = "conversations";
public static final int STATUS_AVAILABLE = 0;
@@ -356,6 +356,19 @@ public class Conversation extends AbstractEntity implements Blockable {
return getContact().isSelf();
}
+ @Override
+ public int compareTo(Conversation another) {
+ final Message left = getLatestMessage();
+ final Message right = another.getLatestMessage();
+ if (left.getTimeSent() > right.getTimeSent()) {
+ return -1;
+ } else if (left.getTimeSent() < right.getTimeSent()) {
+ return 1;
+ } else {
+ return 0;
+ }
+ }
+
public interface OnMessageFound {
void onMessageFound(final Message message);
}