diff options
author | iNPUTmice <daniel@gultsch.de> | 2014-09-19 21:09:54 +0200 |
---|---|---|
committer | iNPUTmice <daniel@gultsch.de> | 2014-09-19 21:09:54 +0200 |
commit | c282ef464565afd66b7a4a0d6c59162d71d9a6fe (patch) | |
tree | e746e974fa6bb01a32f8c1173c70d5714200951c /src | |
parent | 1d23c7e7fbe146a956d55077a99f357d41b6a502 (diff) |
scroll fixes
Diffstat (limited to '')
-rw-r--r-- | src/eu/siacs/conversations/services/XmppConnectionService.java | 8 | ||||
-rw-r--r-- | src/eu/siacs/conversations/ui/ConversationFragment.java | 13 |
2 files changed, 11 insertions, 10 deletions
diff --git a/src/eu/siacs/conversations/services/XmppConnectionService.java b/src/eu/siacs/conversations/services/XmppConnectionService.java index a8900f71..03f81d9a 100644 --- a/src/eu/siacs/conversations/services/XmppConnectionService.java +++ b/src/eu/siacs/conversations/services/XmppConnectionService.java @@ -819,15 +819,15 @@ public class XmppConnectionService extends Service { } }); } - - public List<Message> getMoreMessages(Conversation conversation, - long timestamp) { + + public int loadMoreMessages(Conversation conversation, long timestamp) { List<Message> messages = databaseBackend.getMessages(conversation, 50, timestamp); for (Message message : messages) { message.setConversation(conversation); } - return messages; + conversation.getMessages().addAll(0, messages); + return messages.size(); } public List<Account> getAccounts() { 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<Message> 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(""); |