aboutsummaryrefslogtreecommitdiffstats
path: root/src/main/java/eu/siacs/conversations/entities
diff options
context:
space:
mode:
authorDaniel Gultsch <daniel@gultsch.de>2016-05-22 17:52:27 +0200
committerDaniel Gultsch <daniel@gultsch.de>2016-05-22 17:52:27 +0200
commite5b8302fd9a09552f0b33a956703751bf9da80a7 (patch)
tree8e9493c326b39f62d8c73b99443c106e71508303 /src/main/java/eu/siacs/conversations/entities
parent33218ec32a47292a46d574e5107164b8e8a72e40 (diff)
show first unread message on top after reinit
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, 15 insertions, 0 deletions
diff --git a/src/main/java/eu/siacs/conversations/entities/Conversation.java b/src/main/java/eu/siacs/conversations/entities/Conversation.java
index 10b42b460..23420d69a 100644
--- a/src/main/java/eu/siacs/conversations/entities/Conversation.java
+++ b/src/main/java/eu/siacs/conversations/entities/Conversation.java
@@ -96,6 +96,21 @@ public class Conversation extends AbstractEntity implements Blockable {
this.messagesLeftOnServer = value;
}
+
+ public Message getFirstUnreadMessage() {
+ Message first = null;
+ synchronized (this.messages) {
+ for (int i = messages.size() - 1; i >= 0; --i) {
+ if (messages.get(i).isRead()) {
+ return first;
+ } else {
+ first = messages.get(i);
+ }
+ }
+ }
+ return first;
+ }
+
public Message findUnsentMessageWithUuid(String uuid) {
synchronized(this.messages) {
for (final Message message : this.messages) {