aboutsummaryrefslogtreecommitdiffstats
path: root/src/main/java/de
diff options
context:
space:
mode:
authorChristian Schneppe <christian@pix-art.de>2016-10-18 22:02:37 +0200
committerChristian Schneppe <christian@pix-art.de>2016-10-18 22:02:37 +0200
commit8760759e895506a7df8e6188a668698e820d4469 (patch)
treed3043380ebe72585cf106c434ef3ff5e30f3fe5d /src/main/java/de
parent92c0e993ad3362d1b2ec75f7886bbc2e01f3d253 (diff)
update conversation in database background thread
Diffstat (limited to 'src/main/java/de')
-rw-r--r--src/main/java/de/pixart/messenger/services/XmppConnectionService.java13
-rw-r--r--src/main/java/de/pixart/messenger/ui/ConversationActivity.java15
-rw-r--r--src/main/java/de/pixart/messenger/ui/ConversationFragment.java6
-rw-r--r--src/main/java/de/pixart/messenger/ui/XmppActivity.java2
-rw-r--r--src/main/java/de/pixart/messenger/ui/adapter/MessageAdapter.java2
5 files changed, 19 insertions, 19 deletions
diff --git a/src/main/java/de/pixart/messenger/services/XmppConnectionService.java b/src/main/java/de/pixart/messenger/services/XmppConnectionService.java
index 02725991b..3af13399a 100644
--- a/src/main/java/de/pixart/messenger/services/XmppConnectionService.java
+++ b/src/main/java/de/pixart/messenger/services/XmppConnectionService.java
@@ -1742,7 +1742,7 @@ public class XmppConnectionService extends Service {
);
}
}
- this.databaseBackend.updateConversation(conversation);
+ updateConversation(conversation);
this.conversations.remove(conversation);
updateConversationUi();
}
@@ -2272,7 +2272,7 @@ public class XmppConnectionService extends Service {
}
pushBookmarks(conversation.getAccount());
}
- databaseBackend.updateConversation(conversation);
+ updateConversation(conversation);
joinMuc(conversation);
}
}
@@ -2992,8 +2992,13 @@ public class XmppConnectionService extends Service {
}
}
- public void updateConversation(Conversation conversation) {
- this.databaseBackend.updateConversation(conversation);
+ public void updateConversation(final Conversation conversation) {
+ mDatabaseExecutor.execute(new Runnable() {
+ @Override
+ public void run() {
+ databaseBackend.updateConversation(conversation);
+ }
+ });
}
private void reconnectAccount(final Account account, final boolean force, final boolean interactive) {
diff --git a/src/main/java/de/pixart/messenger/ui/ConversationActivity.java b/src/main/java/de/pixart/messenger/ui/ConversationActivity.java
index baf962392..fd9d3e209 100644
--- a/src/main/java/de/pixart/messenger/ui/ConversationActivity.java
+++ b/src/main/java/de/pixart/messenger/ui/ConversationActivity.java
@@ -804,11 +804,9 @@ public class ConversationActivity extends XmppActivity
@Override
public void onClick(DialogInterface dialog,
int which) {
- conversation
- .setNextEncryption(Message.ENCRYPTION_NONE);
- xmppConnectionService.databaseBackend
- .updateConversation(conversation);
- selectPresenceToAttachFile(attachmentChoice, Message.ENCRYPTION_NONE);
+ conversation.setNextEncryption(Message.ENCRYPTION_NONE);
+ xmppConnectionService.updateConversation(conversation);
+ selectPresenceToAttachFile(attachmentChoice, Message.ENCRYPTION_NONE);
}
});
}
@@ -1096,7 +1094,7 @@ public class ConversationActivity extends XmppActivity
conversation.setNextEncryption(Message.ENCRYPTION_NONE);
break;
}
- xmppConnectionService.databaseBackend.updateConversation(conversation);
+ xmppConnectionService.updateConversation(conversation);
fragment.updateChatMsgHint();
invalidateOptionsMenu();
refreshUi();
@@ -1155,8 +1153,7 @@ public class ConversationActivity extends XmppActivity
till = System.currentTimeMillis() + (durations[which] * 1000);
}
conversation.setMutedTill(till);
- ConversationActivity.this.xmppConnectionService.databaseBackend
- .updateConversation(conversation);
+ ConversationActivity.this.xmppConnectionService.updateConversation(conversation);
updateConversationList();
ConversationActivity.this.mConversationFragment.updateMessages();
invalidateOptionsMenu();
@@ -1167,7 +1164,7 @@ public class ConversationActivity extends XmppActivity
public void unmuteConversation(final Conversation conversation) {
conversation.setMutedTill(0);
- this.xmppConnectionService.databaseBackend.updateConversation(conversation);
+ this.xmppConnectionService.updateConversation(conversation);
updateConversationList();
ConversationActivity.this.mConversationFragment.updateMessages();
invalidateOptionsMenu();
diff --git a/src/main/java/de/pixart/messenger/ui/ConversationFragment.java b/src/main/java/de/pixart/messenger/ui/ConversationFragment.java
index 11da4f130..3dc37c653 100644
--- a/src/main/java/de/pixart/messenger/ui/ConversationFragment.java
+++ b/src/main/java/de/pixart/messenger/ui/ConversationFragment.java
@@ -1252,8 +1252,7 @@ public class ConversationFragment extends Fragment implements EditMessage.Keyboa
int which) {
conversation
.setNextEncryption(Message.ENCRYPTION_NONE);
- xmppService.databaseBackend
- .updateConversation(conversation);
+ xmppService.updateConversation(conversation);
message.setEncryption(Message.ENCRYPTION_NONE);
xmppService.sendMessage(message);
messageSent();
@@ -1281,8 +1280,7 @@ public class ConversationFragment extends Fragment implements EditMessage.Keyboa
conversation
.setNextEncryption(Message.ENCRYPTION_NONE);
message.setEncryption(Message.ENCRYPTION_NONE);
- xmppService.databaseBackend
- .updateConversation(conversation);
+ xmppService.updateConversation(conversation);
xmppService.sendMessage(message);
messageSent();
}
diff --git a/src/main/java/de/pixart/messenger/ui/XmppActivity.java b/src/main/java/de/pixart/messenger/ui/XmppActivity.java
index 6503cbb41..fdaa49eb9 100644
--- a/src/main/java/de/pixart/messenger/ui/XmppActivity.java
+++ b/src/main/java/de/pixart/messenger/ui/XmppActivity.java
@@ -570,7 +570,7 @@ public abstract class XmppActivity extends Activity {
xmppConnectionService.sendPresence(account);
if (conversation != null) {
conversation.setNextEncryption(Message.ENCRYPTION_PGP);
- xmppConnectionService.databaseBackend.updateConversation(conversation);
+ xmppConnectionService.updateConversation(conversation);
refreshUi();
}
if (onSuccess != null) {
diff --git a/src/main/java/de/pixart/messenger/ui/adapter/MessageAdapter.java b/src/main/java/de/pixart/messenger/ui/adapter/MessageAdapter.java
index e3e77c589..258cbba07 100644
--- a/src/main/java/de/pixart/messenger/ui/adapter/MessageAdapter.java
+++ b/src/main/java/de/pixart/messenger/ui/adapter/MessageAdapter.java
@@ -519,7 +519,7 @@ public class MessageAdapter extends ArrayAdapter<Message> {
private void loadMoreMessages(Conversation conversation) {
conversation.setLastClearHistory(0);
- activity.xmppConnectionService.databaseBackend.updateConversation(conversation);
+ activity.xmppConnectionService.updateConversation(conversation);
conversation.setHasMessagesLeftOnServer(true);
conversation.setFirstMamReference(null);
long timestamp = conversation.getLastMessageTransmitted();