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
This commit is contained in:
Daniel Gultsch 2016-07-13 00:20:38 +02:00
parent be4aa2afc9
commit ff1b23b4d9

View file

@ -435,19 +435,19 @@ public class XmppConnectionService extends Service {
} }
message.setCounterpart(conversation.getNextCounterpart()); message.setCounterpart(conversation.getNextCounterpart());
message.setType(Message.TYPE_FILE); message.setType(Message.TYPE_FILE);
String path = getFileBackend().getOriginalPath(uri); final String path = getFileBackend().getOriginalPath(uri);
if (path != null) { mFileAddingExecutor.execute(new Runnable() {
message.setRelativeFilePath(path); @Override
getFileBackend().updateFileParams(message); public void run() {
if (message.getEncryption() == Message.ENCRYPTION_DECRYPTED) { if (path != null) {
getPgpEngine().encrypt(message, callback); message.setRelativeFilePath(path);
} else { getFileBackend().updateFileParams(message);
callback.success(message); if (message.getEncryption() == Message.ENCRYPTION_DECRYPTED) {
} getPgpEngine().encrypt(message, callback);
} else { } else {
mFileAddingExecutor.execute(new Runnable() { callback.success(message);
@Override }
public void run() { } else {
try { try {
getFileBackend().copyFileToPrivateStorage(message, uri); getFileBackend().copyFileToPrivateStorage(message, uri);
getFileBackend().updateFileParams(message); getFileBackend().updateFileParams(message);
@ -455,7 +455,7 @@ public class XmppConnectionService extends Service {
final PgpEngine pgpEngine = getPgpEngine(); final PgpEngine pgpEngine = getPgpEngine();
if (pgpEngine != null) { if (pgpEngine != null) {
pgpEngine.encrypt(message, callback); pgpEngine.encrypt(message, callback);
} else if (callback != null){ } else if (callback != null) {
callback.error(R.string.unable_to_connect_to_keychain, null); callback.error(R.string.unable_to_connect_to_keychain, null);
} }
} else { } else {
@ -465,8 +465,8 @@ public class XmppConnectionService extends Service {
callback.error(e.getResId(), message); callback.error(e.getResId(), message);
} }
} }
}); }
} });
} }
public void attachImageToConversation(final Conversation conversation, final Uri uri, final UiCallback<Message> callback) { public void attachImageToConversation(final Conversation conversation, final Uri uri, final UiCallback<Message> callback) {