aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorDaniel Gultsch <daniel@gultsch.de>2016-03-03 11:14:59 +0100
committerDaniel Gultsch <daniel@gultsch.de>2016-03-03 11:14:59 +0100
commitc9e4b332bfd1b8ddf91f3b1017cfca936ba9cbec (patch)
tree6a024c8e68dada5fa0999046b43adb254033c2b8 /src
parentaaf64732b0e04d0b95407c5420da08c8c1752ec6 (diff)
don't break with srcoll events on empty message lists
Diffstat (limited to 'src')
-rw-r--r--src/main/java/eu/siacs/conversations/ui/ConversationFragment.java9
1 files changed, 7 insertions, 2 deletions
diff --git a/src/main/java/eu/siacs/conversations/ui/ConversationFragment.java b/src/main/java/eu/siacs/conversations/ui/ConversationFragment.java
index 15e4b985..09d98e83 100644
--- a/src/main/java/eu/siacs/conversations/ui/ConversationFragment.java
+++ b/src/main/java/eu/siacs/conversations/ui/ConversationFragment.java
@@ -123,7 +123,7 @@ public class ConversationFragment extends Fragment implements EditMessage.Keyboa
private int getIndexOf(String uuid, List<Message> messages) {
if (uuid == null) {
- return 0;
+ return messages.size() - 1;
}
for(int i = 0; i < messages.size(); ++i) {
if (uuid.equals(messages.get(i).getUuid())) {
@@ -164,7 +164,12 @@ public class ConversationFragment extends Fragment implements EditMessage.Keyboa
@Override
public void run() {
final int oldPosition = messagesView.getFirstVisiblePosition();
- Message message = messageList.get(oldPosition);
+ final Message message;
+ if (oldPosition < messageList.size()) {
+ message = messageList.get(oldPosition);
+ } else {
+ message = null;
+ }
String uuid = message != null ? message.getUuid() : null;
View v = messagesView.getChildAt(0);
final int pxOffset = (v == null) ? 0 : v.getTop();