diff options
author | Christian Schneppe <christian@pix-art.de> | 2018-04-23 21:36:56 +0200 |
---|---|---|
committer | Christian Schneppe <christian@pix-art.de> | 2018-04-23 21:36:56 +0200 |
commit | a66f8bffab6336082ba0e7393110256e08f656b1 (patch) | |
tree | 5040e8972c6df1f05637d3f21bfbafb89c7486c1 /src/main/java | |
parent | fd097d068c3858bf2cc7ebfb3a86cafad0ebe4bb (diff) |
synchronize around getting last visibile uuid
Diffstat (limited to 'src/main/java')
-rw-r--r-- | src/main/java/de/pixart/messenger/ui/ConversationFragment.java | 26 |
1 files changed, 14 insertions, 12 deletions
diff --git a/src/main/java/de/pixart/messenger/ui/ConversationFragment.java b/src/main/java/de/pixart/messenger/ui/ConversationFragment.java index bc3a7c890..0b399393d 100644 --- a/src/main/java/de/pixart/messenger/ui/ConversationFragment.java +++ b/src/main/java/de/pixart/messenger/ui/ConversationFragment.java @@ -1858,20 +1858,22 @@ public class ConversationFragment extends XmppFragment implements EditMessage.Ke if (binding == null) { return null; } - int pos = binding.messagesView.getLastVisiblePosition(); - if (pos >= 0) { - Message message = null; - for (int i = pos; i >= 0; --i) { - message = (Message) binding.messagesView.getItemAtPosition(i); - if (message.getType() != Message.TYPE_STATUS) { - break; + synchronized (this.messageList) { + int pos = binding.messagesView.getLastVisiblePosition(); + if (pos >= 0) { + Message message = null; + for (int i = pos; i >= 0; --i) { + message = (Message) binding.messagesView.getItemAtPosition(i); + if (message.getType() != Message.TYPE_STATUS) { + break; + } } - } - if (message != null) { - while (message.next() != null && message.next().wasMergedIntoPrevious()) { - message = message.next(); + if (message != null) { + while (message.next() != null && message.next().wasMergedIntoPrevious()) { + message = message.next(); + } + return message.getUuid(); } - return message.getUuid(); } } return null; |