diff options
author | Christian Schneppe <christian@pix-art.de> | 2018-04-24 21:48:40 +0200 |
---|---|---|
committer | Christian Schneppe <christian@pix-art.de> | 2018-04-24 21:48:40 +0200 |
commit | 2a1374a008970895a2b68c778ba2a05903798fa6 (patch) | |
tree | 97410713419376dd5a21e4766b694283e06633bf /src/main/java/de/pixart/messenger/services/XmppConnectionService.java | |
parent | 832134a5e45a7ec4eb500b5d3e1a1b2f64d536b4 (diff) |
load currently open conversation faster
Diffstat (limited to '')
-rw-r--r-- | src/main/java/de/pixart/messenger/services/XmppConnectionService.java | 24 |
1 files changed, 19 insertions, 5 deletions
diff --git a/src/main/java/de/pixart/messenger/services/XmppConnectionService.java b/src/main/java/de/pixart/messenger/services/XmppConnectionService.java index 07a1fcca8..a6e798bc8 100644 --- a/src/main/java/de/pixart/messenger/services/XmppConnectionService.java +++ b/src/main/java/de/pixart/messenger/services/XmppConnectionService.java @@ -117,6 +117,7 @@ import de.pixart.messenger.utils.Namespace; import de.pixart.messenger.utils.OnPhoneContactsLoadedListener; import de.pixart.messenger.utils.PRNGFixes; import de.pixart.messenger.utils.PhoneHelper; +import de.pixart.messenger.utils.QuickLoader; import de.pixart.messenger.utils.ReplacingSerialSingleThreadExecutor; import de.pixart.messenger.utils.ReplacingTaskManager; import de.pixart.messenger.utils.Resolver; @@ -1581,11 +1582,17 @@ public class XmppConnectionService extends Service { loadPhoneContacts(); Log.d(Config.LOGTAG, "restoring messages..."); final long startMessageRestore = SystemClock.elapsedRealtime(); - for (Conversation conversation : conversations) { - conversation.addAll(0, databaseBackend.getMessages(conversation, Config.PAGE_SIZE)); - checkDeletedFiles(conversation); - conversation.findUnsentTextMessages(message -> markMessage(message, Message.STATUS_WAITING)); - conversation.findUnreadMessages(message -> mNotificationService.pushFromBacklog(message)); + final Conversation quickLoad = QuickLoader.get(this.conversations); + if (quickLoad != null) { + restoreMessages(quickLoad); + updateConversationUi(); + final long diffMessageRestore = SystemClock.elapsedRealtime() - startMessageRestore; + Log.d(Config.LOGTAG, "quickly restored " + quickLoad.getName() + " after " + diffMessageRestore + "ms"); + } + for (Conversation conversation : this.conversations) { + if (quickLoad != conversation) { + restoreMessages(conversation); + } } mNotificationService.finishBacklog(false); restoredFromDatabaseLatch.countDown(); @@ -1597,6 +1604,13 @@ public class XmppConnectionService extends Service { } } + private void restoreMessages(Conversation conversation) { + conversation.addAll(0, databaseBackend.getMessages(conversation, Config.PAGE_SIZE)); + checkDeletedFiles(conversation); + conversation.findUnsentTextMessages(message -> markMessage(message, Message.STATUS_WAITING)); + conversation.findUnreadMessages(message -> mNotificationService.pushFromBacklog(message)); + } + public void loadPhoneContacts() { mContactMergerExecutor.execute(() -> PhoneHelper.loadPhoneContacts(XmppConnectionService.this, new OnPhoneContactsLoadedListener() { @Override |