mirror of
https://github.com/moparisthebest/Conversations
synced 2024-11-28 03:32:15 -05:00
moved db calls made from UI into serial background thread
This commit is contained in:
parent
ef7857ac8d
commit
8553d5a563
@ -1417,7 +1417,13 @@ public class XmppConnectionService extends Service implements OnPhoneContactsLoa
|
|||||||
if (account.getXmppConnection() != null) {
|
if (account.getXmppConnection() != null) {
|
||||||
this.disconnect(account, true);
|
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);
|
this.accounts.remove(account);
|
||||||
updateAccountUi();
|
updateAccountUi();
|
||||||
getNotificationService().updateErrorNotification();
|
getNotificationService().updateErrorNotification();
|
||||||
@ -2617,8 +2623,17 @@ public class XmppConnectionService extends Service implements OnPhoneContactsLoa
|
|||||||
|
|
||||||
public void markRead(final Conversation conversation) {
|
public void markRead(final Conversation conversation) {
|
||||||
mNotificationService.clear(conversation);
|
mNotificationService.clear(conversation);
|
||||||
for (Message message : conversation.markRead()) {
|
final List<Message> readMessages = conversation.markRead();
|
||||||
databaseBackend.updateMessage(message);
|
if (readMessages.size() > 0) {
|
||||||
|
Runnable runnable = new Runnable() {
|
||||||
|
@Override
|
||||||
|
public void run() {
|
||||||
|
for (Message message : readMessages) {
|
||||||
|
databaseBackend.updateMessage(message);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
mDatabaseExecutor.execute(runnable);
|
||||||
}
|
}
|
||||||
updateUnreadCountBadge();
|
updateUnreadCountBadge();
|
||||||
}
|
}
|
||||||
@ -2834,12 +2849,13 @@ public class XmppConnectionService extends Service implements OnPhoneContactsLoa
|
|||||||
conversation.clearMessages();
|
conversation.clearMessages();
|
||||||
conversation.setHasMessagesLeftOnServer(false); //avoid messages getting loaded through mam
|
conversation.setHasMessagesLeftOnServer(false); //avoid messages getting loaded through mam
|
||||||
conversation.resetLastMessageTransmitted();
|
conversation.resetLastMessageTransmitted();
|
||||||
new Thread(new Runnable() {
|
Runnable runnable = new Runnable() {
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
databaseBackend.deleteMessagesInConversation(conversation);
|
databaseBackend.deleteMessagesInConversation(conversation);
|
||||||
}
|
}
|
||||||
}).start();
|
};
|
||||||
|
mDatabaseExecutor.execute(runnable);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void sendBlockRequest(final Blockable blockable) {
|
public void sendBlockRequest(final Blockable blockable) {
|
||||||
|
Loading…
Reference in New Issue
Block a user