From 28733e052ff1172a0b16ee8d52f1545b0ef32de3 Mon Sep 17 00:00:00 2001 From: Daniel Gultsch Date: Thu, 4 Feb 2016 16:29:17 +0100 Subject: fixed performance regression in on scroll listener --- .../eu/siacs/conversations/services/XmppConnectionService.java | 4 ++-- src/main/java/eu/siacs/conversations/ui/ConversationFragment.java | 7 ++++++- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/src/main/java/eu/siacs/conversations/services/XmppConnectionService.java b/src/main/java/eu/siacs/conversations/services/XmppConnectionService.java index 0973036c..4fa5ddff 100644 --- a/src/main/java/eu/siacs/conversations/services/XmppConnectionService.java +++ b/src/main/java/eu/siacs/conversations/services/XmppConnectionService.java @@ -1216,7 +1216,6 @@ public class XmppConnectionService extends Service implements OnPhoneContactsLoa if (XmppConnectionService.this.getMessageArchiveService().queryInProgress(conversation, callback)) { return; } else if (timestamp == 0) { - callback.onMoreMessagesLoaded(0, conversation); return; } Log.d(Config.LOGTAG, "load more messages for " + conversation.getName() + " prior to " + MessageGenerator.getTimestamp(timestamp)); @@ -1230,7 +1229,8 @@ public class XmppConnectionService extends Service implements OnPhoneContactsLoa checkDeletedFiles(conversation); callback.onMoreMessagesLoaded(messages.size(), conversation); } else if (conversation.hasMessagesLeftOnServer() - && account.isOnlineAndConnected()) { + && account.isOnlineAndConnected() + && conversation.getLastClearHistory() == 0) { if ((conversation.getMode() == Conversation.MODE_SINGLE && account.getXmppConnection().getFeatures().mam()) || (conversation.getMode() == Conversation.MODE_MULTI && conversation.getMucOptions().mamSupport())) { MessageArchiveService.Query query = getMessageArchiveService().query(conversation, 0, timestamp); diff --git a/src/main/java/eu/siacs/conversations/ui/ConversationFragment.java b/src/main/java/eu/siacs/conversations/ui/ConversationFragment.java index 42e442ed..5874adae 100644 --- a/src/main/java/eu/siacs/conversations/ui/ConversationFragment.java +++ b/src/main/java/eu/siacs/conversations/ui/ConversationFragment.java @@ -146,7 +146,12 @@ public class ConversationFragment extends Fragment implements EditMessage.Keyboa int visibleItemCount, int totalItemCount) { synchronized (ConversationFragment.this.messageList) { if (firstVisibleItem < 5 && messagesLoaded && messageList.size() > 0) { - long timestamp = ConversationFragment.this.messageList.get(0).getTimeSent(); + long timestamp; + if (messageList.get(0).getType() == Message.TYPE_STATUS && messageList.size() >= 2) { + timestamp = messageList.get(1).getTimeSent(); + } else { + timestamp = messageList.get(0).getTimeSent(); + } messagesLoaded = false; activity.xmppConnectionService.loadMoreMessages(conversation, timestamp, new XmppConnectionService.OnMoreMessagesLoaded() { @Override -- cgit v1.2.3