aboutsummaryrefslogtreecommitdiffstats
path: root/src/main/java/eu/siacs/conversations/entities/Message.java
diff options
context:
space:
mode:
Diffstat (limited to 'src/main/java/eu/siacs/conversations/entities/Message.java')
-rw-r--r--src/main/java/eu/siacs/conversations/entities/Message.java13
1 files changed, 7 insertions, 6 deletions
diff --git a/src/main/java/eu/siacs/conversations/entities/Message.java b/src/main/java/eu/siacs/conversations/entities/Message.java
index 2cced3b3..c7a92d84 100644
--- a/src/main/java/eu/siacs/conversations/entities/Message.java
+++ b/src/main/java/eu/siacs/conversations/entities/Message.java
@@ -320,8 +320,8 @@ public class Message extends AbstractEntity {
}
public Message next() {
- if (this.mNextMessage == null) {
- synchronized (this.conversation.messages) {
+ synchronized (this.conversation.messages) {
+ if (this.mNextMessage == null) {
int index = this.conversation.messages.indexOf(this);
if (index < 0
|| index >= this.conversation.getMessages().size() - 1) {
@@ -331,13 +331,14 @@ public class Message extends AbstractEntity {
.get(index + 1);
}
}
+ return this.mNextMessage;
}
- return this.mNextMessage;
}
public Message prev() {
- if (this.mPreviousMessage == null) {
- synchronized (this.conversation.messages) {
+ synchronized (this.conversation.messages) {
+ if (this.mPreviousMessage == null) {
+
int index = this.conversation.messages.indexOf(this);
if (index <= 0 || index > this.conversation.messages.size()) {
this.mPreviousMessage = null;
@@ -346,8 +347,8 @@ public class Message extends AbstractEntity {
.get(index - 1);
}
}
+ return this.mPreviousMessage;
}
- return this.mPreviousMessage;
}
public boolean mergeable(final Message message) {