diff options
author | steckbrief <steckbrief@chefmail.de> | 2015-12-06 16:21:39 +0100 |
---|---|---|
committer | steckbrief <steckbrief@chefmail.de> | 2015-12-06 16:21:39 +0100 |
commit | aa6a2e1c182858e7bcc077f5220546e08df12ec1 (patch) | |
tree | 12cce9117bfa7bda7dc78b9809f772e0439fc7c7 /src/main/java/eu/siacs/conversations | |
parent | 734511b0fa15fa6ceb88c6b0ab4791139f7ffc8d (diff) | |
parent | eb5a7a5392ec93976d91d5576a3496ceac473d03 (diff) |
Merge remote-tracking branch 'remotes/origin/trz/rename' into trz/rebase
Diffstat (limited to 'src/main/java/eu/siacs/conversations')
3 files changed, 15 insertions, 2 deletions
diff --git a/src/main/java/eu/siacs/conversations/services/MessageArchiveService.java b/src/main/java/eu/siacs/conversations/services/MessageArchiveService.java index 6cbb43d6..58d59288 100644 --- a/src/main/java/eu/siacs/conversations/services/MessageArchiveService.java +++ b/src/main/java/eu/siacs/conversations/services/MessageArchiveService.java @@ -134,10 +134,10 @@ public class MessageArchiveService implements OnAdvancedStreamFeaturesLoaded { if (conversation.setLastMessageTransmitted(query.getEnd())) { this.mXmppConnectionService.databaseBackend.updateConversation(conversation); } - conversation.setHasMessagesLeftOnServer(query.getMessageCount() > 0); if (query.hasCallback()) { query.callback(); } else { + conversation.setHasMessagesLeftOnServer(query.getMessageCount() > 0); this.mXmppConnectionService.updateConversationUi(); } } else { diff --git a/src/main/java/eu/siacs/conversations/ui/listeners/ConversationMoreMessagesLoadedListener.java b/src/main/java/eu/siacs/conversations/ui/listeners/ConversationMoreMessagesLoadedListener.java index a7354eec..a5c5e2aa 100644 --- a/src/main/java/eu/siacs/conversations/ui/listeners/ConversationMoreMessagesLoadedListener.java +++ b/src/main/java/eu/siacs/conversations/ui/listeners/ConversationMoreMessagesLoadedListener.java @@ -29,16 +29,24 @@ public class ConversationMoreMessagesLoadedListener implements XmppConnectionSer The current loading status */ private boolean loadingMessages = false; + /** + * Whether the user is loading only history messages or not. + * History messages are messages which are older than the oldest in the database. + */ + private boolean loadHistory = true; public ConversationMoreMessagesLoadedListener(SwipyRefreshLayout swipeLayout, List<Message> messageList, ConversationFragment fragment, ListView messagesView, MessageAdapter messageListAdapter) { this.swipeLayout = swipeLayout; this.messageList = messageList; - this.fragment = fragment; this.messagesView = messagesView; this.messageListAdapter = messageListAdapter; } + public void setLoadHistory(boolean value) { + this.loadHistory = value; + } + public void setLoadingInProgress() { this.loadingMessages = true; } @@ -62,6 +70,9 @@ public class ConversationMoreMessagesLoadedListener implements XmppConnectionSer } // No new messages are loaded if (0 == c) { + if (this.loadHistory) { + conversation.setHasMessagesLeftOnServer(false); + } activity.runOnUiThread(new Runnable() { @Override public void run() { diff --git a/src/main/java/eu/siacs/conversations/ui/listeners/ConversationSwipeRefreshListener.java b/src/main/java/eu/siacs/conversations/ui/listeners/ConversationSwipeRefreshListener.java index 7b3b97aa..f2b5ca22 100644 --- a/src/main/java/eu/siacs/conversations/ui/listeners/ConversationSwipeRefreshListener.java +++ b/src/main/java/eu/siacs/conversations/ui/listeners/ConversationSwipeRefreshListener.java @@ -43,6 +43,7 @@ public class ConversationSwipeRefreshListener implements SwipyRefreshLayout.OnRe timestamp = this.messageList.get(0).getTimeSent(); // works only because of the ordering (last msg = first msg in list) } ConversationActivity activity = (ConversationActivity) fragment.getActivity(); + this.listener.setLoadHistory(true); activity.xmppConnectionService.loadMoreMessages(activity.getSelectedConversation(), timestamp, this.listener); } else if (SwipyRefreshLayoutDirection.BOTTOM == direction) { Logging.d("mam", "loading missing messages from mam (last session establishing or last received message)"); @@ -53,6 +54,7 @@ public class ConversationSwipeRefreshListener implements SwipyRefreshLayout.OnRe long startTimestamp = Math.min(lastSessionEstablished, lastReceivedMessage); MessageArchiveService.Query query = activity.xmppConnectionService.getMessageArchiveService().query(activity.getSelectedConversation(), startTimestamp, System.currentTimeMillis()); if (query != null) { + this.listener.setLoadHistory(false); query.setCallback(this.listener); } else { activity.runOnUiThread(new Runnable() { |