diff options
author | Daniel Gultsch <daniel@gultsch.de> | 2016-07-13 00:20:38 +0200 |
---|---|---|
committer | Daniel Gultsch <daniel@gultsch.de> | 2016-07-13 00:20:38 +0200 |
commit | ff1b23b4d9fb389b31e1fefe117898d4da1ea0d5 (patch) | |
tree | ef6705603f37a9f1daefa90441db53a90233a8a0 /src/main/java/eu | |
parent | be4aa2afc96b86c89c2fc37735a4b0cf328d7415 (diff) |
call update file params from thread
now that file params has more work to do we should make sure we always call it from a sperate thread
Diffstat (limited to 'src/main/java/eu')
-rw-r--r-- | src/main/java/eu/siacs/conversations/services/XmppConnectionService.java | 32 |
1 files changed, 16 insertions, 16 deletions
diff --git a/src/main/java/eu/siacs/conversations/services/XmppConnectionService.java b/src/main/java/eu/siacs/conversations/services/XmppConnectionService.java index b85e6f42..02c0650c 100644 --- a/src/main/java/eu/siacs/conversations/services/XmppConnectionService.java +++ b/src/main/java/eu/siacs/conversations/services/XmppConnectionService.java @@ -435,19 +435,19 @@ public class XmppConnectionService extends Service { } message.setCounterpart(conversation.getNextCounterpart()); message.setType(Message.TYPE_FILE); - String path = getFileBackend().getOriginalPath(uri); - if (path != null) { - message.setRelativeFilePath(path); - getFileBackend().updateFileParams(message); - if (message.getEncryption() == Message.ENCRYPTION_DECRYPTED) { - getPgpEngine().encrypt(message, callback); - } else { - callback.success(message); - } - } else { - mFileAddingExecutor.execute(new Runnable() { - @Override - public void run() { + final String path = getFileBackend().getOriginalPath(uri); + mFileAddingExecutor.execute(new Runnable() { + @Override + public void run() { + if (path != null) { + message.setRelativeFilePath(path); + getFileBackend().updateFileParams(message); + if (message.getEncryption() == Message.ENCRYPTION_DECRYPTED) { + getPgpEngine().encrypt(message, callback); + } else { + callback.success(message); + } + } else { try { getFileBackend().copyFileToPrivateStorage(message, uri); getFileBackend().updateFileParams(message); @@ -455,7 +455,7 @@ public class XmppConnectionService extends Service { final PgpEngine pgpEngine = getPgpEngine(); if (pgpEngine != null) { pgpEngine.encrypt(message, callback); - } else if (callback != null){ + } else if (callback != null) { callback.error(R.string.unable_to_connect_to_keychain, null); } } else { @@ -465,8 +465,8 @@ public class XmppConnectionService extends Service { callback.error(e.getResId(), message); } } - }); - } + } + }); } public void attachImageToConversation(final Conversation conversation, final Uri uri, final UiCallback<Message> callback) { |