diff options
author | Daniel Gultsch <daniel@gultsch.de> | 2015-10-29 17:20:01 +0100 |
---|---|---|
committer | Daniel Gultsch <daniel@gultsch.de> | 2015-10-29 17:20:01 +0100 |
commit | 8553d5a5635afb16d294d00f14381ca2c0dae6a1 (patch) | |
tree | aca7c46fe522c55e73f92d92c56ee4140e7e73ac /src/main/java/eu/siacs/conversations/services/XmppConnectionService.java | |
parent | ef7857ac8da2a5c604ff48620e2480e4aa52661f (diff) |
moved db calls made from UI into serial background thread
Diffstat (limited to '')
-rw-r--r-- | src/main/java/eu/siacs/conversations/services/XmppConnectionService.java | 26 |
1 files changed, 21 insertions, 5 deletions
diff --git a/src/main/java/eu/siacs/conversations/services/XmppConnectionService.java b/src/main/java/eu/siacs/conversations/services/XmppConnectionService.java index ba235a38..9f3527f1 100644 --- a/src/main/java/eu/siacs/conversations/services/XmppConnectionService.java +++ b/src/main/java/eu/siacs/conversations/services/XmppConnectionService.java @@ -1417,7 +1417,13 @@ public class XmppConnectionService extends Service implements OnPhoneContactsLoa if (account.getXmppConnection() != null) { this.disconnect(account, true); } - databaseBackend.deleteAccount(account); + Runnable runnable = new Runnable() { + @Override + public void run() { + databaseBackend.deleteAccount(account); + } + }; + mDatabaseExecutor.execute(runnable); this.accounts.remove(account); updateAccountUi(); getNotificationService().updateErrorNotification(); @@ -2617,8 +2623,17 @@ public class XmppConnectionService extends Service implements OnPhoneContactsLoa public void markRead(final Conversation conversation) { mNotificationService.clear(conversation); - for (Message message : conversation.markRead()) { - databaseBackend.updateMessage(message); + final List<Message> readMessages = conversation.markRead(); + if (readMessages.size() > 0) { + Runnable runnable = new Runnable() { + @Override + public void run() { + for (Message message : readMessages) { + databaseBackend.updateMessage(message); + } + } + }; + mDatabaseExecutor.execute(runnable); } updateUnreadCountBadge(); } @@ -2834,12 +2849,13 @@ public class XmppConnectionService extends Service implements OnPhoneContactsLoa conversation.clearMessages(); conversation.setHasMessagesLeftOnServer(false); //avoid messages getting loaded through mam conversation.resetLastMessageTransmitted(); - new Thread(new Runnable() { + Runnable runnable = new Runnable() { @Override public void run() { databaseBackend.deleteMessagesInConversation(conversation); } - }).start(); + }; + mDatabaseExecutor.execute(runnable); } public void sendBlockRequest(final Blockable blockable) { |