aboutsummaryrefslogtreecommitdiffstats
path: root/src/main/java/de/pixart/messenger/entities
diff options
context:
space:
mode:
authorChristian Schneppe <christian@pix-art.de>2017-08-13 23:07:37 +0200
committerChristian Schneppe <christian@pix-art.de>2017-08-13 23:07:37 +0200
commitd31dd9cbe497f23e44ef92d09c5b13446f4c856f (patch)
tree971a54797db61cb833e95119b68937aabd1b71a0 /src/main/java/de/pixart/messenger/entities
parentdfdf520ed82a18f2b5af4d458c823252e37d46a4 (diff)
code cleanup and synchronized getMarkableMessage()
Diffstat (limited to 'src/main/java/de/pixart/messenger/entities')
-rw-r--r--src/main/java/de/pixart/messenger/entities/Conversation.java12
1 files changed, 5 insertions, 7 deletions
diff --git a/src/main/java/de/pixart/messenger/entities/Conversation.java b/src/main/java/de/pixart/messenger/entities/Conversation.java
index 9646a3990..5744d67a7 100644
--- a/src/main/java/de/pixart/messenger/entities/Conversation.java
+++ b/src/main/java/de/pixart/messenger/entities/Conversation.java
@@ -470,13 +470,11 @@ public class Conversation extends AbstractEntity implements Blockable, Comparabl
}
public Message getLatestMarkableMessage() {
- for (int i = this.messages.size() - 1; i >= 0; --i) {
- if (this.messages.get(i).getStatus() <= Message.STATUS_RECEIVED
- && this.messages.get(i).markable) {
- if (this.messages.get(i).isRead()) {
- return null;
- } else {
- return this.messages.get(i);
+ synchronized (this.messages) {
+ for (int i = this.messages.size() - 1; i >= 0; --i) {
+ final Message message = this.messages.get(i);
+ if (message.getStatus() <= Message.STATUS_RECEIVED && message.markable) {
+ return message.isRead() ? null : message;
}
}
}