diff options
author | steckbrief <steckbrief@chefmail.de> | 2016-03-10 22:54:13 +0100 |
---|---|---|
committer | steckbrief <steckbrief@chefmail.de> | 2016-03-10 22:54:13 +0100 |
commit | 27c9c0aa21e3ec1a5801f6c3279caf0cd4fe9248 (patch) | |
tree | 07b46aec0b360d5d8f988988fd447cb76f6cf8a3 /src/main/java/de/thedevstack/conversationsplus/services/MessageArchiveService.java | |
parent | 58ddfef266c15983850fee500511bc63f65bb53b (diff) |
Fixes FS#157: Trigger loading messages from MAM in MUC does not end
Diffstat (limited to 'src/main/java/de/thedevstack/conversationsplus/services/MessageArchiveService.java')
-rw-r--r-- | src/main/java/de/thedevstack/conversationsplus/services/MessageArchiveService.java | 39 |
1 files changed, 23 insertions, 16 deletions
diff --git a/src/main/java/de/thedevstack/conversationsplus/services/MessageArchiveService.java b/src/main/java/de/thedevstack/conversationsplus/services/MessageArchiveService.java index a61ade40..f2298d8c 100644 --- a/src/main/java/de/thedevstack/conversationsplus/services/MessageArchiveService.java +++ b/src/main/java/de/thedevstack/conversationsplus/services/MessageArchiveService.java @@ -96,18 +96,25 @@ public class MessageArchiveService implements OnAdvancedStreamFeaturesLoaded { return this.query(conversation,conversation.getLastMessageTransmitted(),end); } - public Query query(Conversation conversation, long start, long end) { - synchronized (this.queries) { - if (start > end) { - return null; - } - final Query query = new Query(conversation, start, end,PagingOrder.REVERSE); - query.reference = conversation.getFirstMamReference(); - this.queries.add(query); - this.execute(query); - return query; - } - } + public Query query(Conversation conversation, long start, long end) { + return this.query(conversation, start, end, null); + } + + public Query query(Conversation conversation, long start, long end, XmppConnectionService.OnMoreMessagesLoaded callback) { + synchronized (this.queries) { + if (start > end) { + return null; + } + final Query query = new Query(conversation, start, end,PagingOrder.REVERSE); + query.reference = conversation.getFirstMamReference(); + this.queries.add(query); + if (null != callback) { + query.setCallback(callback); + } + this.execute(query); + return query; + } + } public void executePendingQueries(final Account account) { List<Query> pending = new ArrayList<>(); @@ -137,7 +144,7 @@ public class MessageArchiveService implements OnAdvancedStreamFeaturesLoaded { synchronized (MessageArchiveService.this.queries) { MessageArchiveService.this.queries.remove(query); if (query.hasCallback()) { - query.callback(false); + query.callback(); } } } else if (packet.getType() != IqPacket.TYPE.RESULT) { @@ -169,7 +176,7 @@ public class MessageArchiveService implements OnAdvancedStreamFeaturesLoaded { } } if (query.hasCallback()) { - query.callback(done); + query.callback(); } else { if (null != conversation) { conversation.setHasMessagesLeftOnServer(query.getMessageCount() > 0); @@ -335,10 +342,10 @@ public class MessageArchiveService implements OnAdvancedStreamFeaturesLoaded { this.callback = callback; } - public void callback(boolean done) { + public void callback() { if (this.callback != null) { this.callback.onMoreMessagesLoaded(messageCount,conversation); - if (done) { + if (messageCount <= 0) { this.callback.informUser(R.string.no_more_history_on_server); } } |