From c282ef464565afd66b7a4a0d6c59162d71d9a6fe Mon Sep 17 00:00:00 2001 From: iNPUTmice Date: Fri, 19 Sep 2014 21:09:54 +0200 Subject: scroll fixes --- src/eu/siacs/conversations/ui/ConversationFragment.java | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) (limited to 'src/eu/siacs/conversations/ui/ConversationFragment.java') diff --git a/src/eu/siacs/conversations/ui/ConversationFragment.java b/src/eu/siacs/conversations/ui/ConversationFragment.java index e09958cb..ea0a6f14 100644 --- a/src/eu/siacs/conversations/ui/ConversationFragment.java +++ b/src/eu/siacs/conversations/ui/ConversationFragment.java @@ -165,14 +165,15 @@ public class ConversationFragment extends Fragment { if (firstVisibleItem == 0 && messagesLoaded) { long timestamp = messageList.get(0).getTimeSent(); messagesLoaded = false; - List messages = activity.xmppConnectionService - .getMoreMessages(conversation, timestamp); - messageList.addAll(0, messages); + int size = activity.xmppConnectionService.loadMoreMessages( + conversation, timestamp); + messageList.clear(); + messageList.addAll(conversation.getMessages()); messageListAdapter.notifyDataSetChanged(); - if (messages.size() != 0) { + if (size != 0) { messagesLoaded = true; } - messagesView.setSelectionFromTop(messages.size() + 1, 0); + messagesView.setSelectionFromTop(size + 1, 0); } } }; @@ -492,7 +493,7 @@ public class ConversationFragment extends Fragment { private void messageSent() { int size = this.messageList.size(); - if (size >= 1) { + if (size >= 1 && this.messagesView.getLastVisiblePosition() != size - 1) { messagesView.setSelection(size - 1); } mEditMessage.setText(""); -- cgit v1.2.3