aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorChristian Schneppe <christian@pix-art.de>2018-11-30 21:06:45 +0100
committerChristian Schneppe <christian@pix-art.de>2018-11-30 21:06:45 +0100
commit17a326ecb42bb0472d2005bbf40e4f96784c3f49 (patch)
tree3b163841ff1b0b30e69b8d47a9fb310592d7943c /src
parentbe9c267a053bc1d073a6948f5c644151f83cbfe7 (diff)
run expireOldMessages in background task
Diffstat (limited to 'src')
-rw-r--r--src/main/java/de/pixart/messenger/services/XmppConnectionService.java13
1 files changed, 9 insertions, 4 deletions
diff --git a/src/main/java/de/pixart/messenger/services/XmppConnectionService.java b/src/main/java/de/pixart/messenger/services/XmppConnectionService.java
index 7c5d2b64d..708200355 100644
--- a/src/main/java/de/pixart/messenger/services/XmppConnectionService.java
+++ b/src/main/java/de/pixart/messenger/services/XmppConnectionService.java
@@ -1027,10 +1027,10 @@ public class XmppConnectionService extends Service {
public void expireOldMessages(final boolean resetHasMessagesLeftOnServer) {
mLastExpiryRun.set(SystemClock.elapsedRealtime());
- mDatabaseWriterExecutor.execute(() -> {
+ Runnable runnable = () -> {
long timestamp = getAutomaticMessageDeletionDate();
if (timestamp > 0) {
- databaseBackend.expireOldMessages(timestamp);
+ expireOldMessages(timestamp);
synchronized (XmppConnectionService.this.conversations) {
for (Conversation conversation : XmppConnectionService.this.conversations) {
conversation.expireOldMessages(timestamp);
@@ -1042,7 +1042,8 @@ public class XmppConnectionService extends Service {
}
updateConversationUi();
}
- });
+ };
+ mDatabaseWriterExecutor.execute((runnable));
}
public boolean hasInternetConnection() {
@@ -1716,7 +1717,7 @@ public class XmppConnectionService extends Service {
mLastExpiryRun.set(SystemClock.elapsedRealtime());
if (deletionDate > 0) {
Log.d(Config.LOGTAG, "deleting messages that are older than " + AbstractGenerator.getTimestamp(deletionDate));
- databaseBackend.expireOldMessages(deletionDate);
+ expireOldMessages(deletionDate);
}
Log.d(Config.LOGTAG, "restoring roster...");
for (Account account : accounts) {
@@ -4558,4 +4559,8 @@ public class XmppConnectionService extends Service {
onStartCommand(intent, 0, 0);
}
}
+
+ private void expireOldMessages(long timestamp) {
+ databaseBackend.expireOldMessages(timestamp);
+ }
}