aboutsummaryrefslogtreecommitdiffstats
path: root/src/main/java/de/pixart
diff options
context:
space:
mode:
authorChristian Schneppe <christian@pix-art.de>2017-09-24 21:40:58 +0200
committerChristian Schneppe <christian@pix-art.de>2017-09-24 21:40:58 +0200
commitdf2203b155c988bd96b4cfa69bdaa2a5c2e90dd8 (patch)
treee2ead744e247a38a45e25779a2220a7066700985 /src/main/java/de/pixart
parent8334fe93f1e9610176f4bf13e429b5459cfd96ed (diff)
execute video compression on seperate thread
Diffstat (limited to 'src/main/java/de/pixart')
-rw-r--r--src/main/java/de/pixart/messenger/services/AttachFileToConversationRunnable.java4
-rw-r--r--src/main/java/de/pixart/messenger/services/XmppConnectionService.java9
2 files changed, 11 insertions, 2 deletions
diff --git a/src/main/java/de/pixart/messenger/services/AttachFileToConversationRunnable.java b/src/main/java/de/pixart/messenger/services/AttachFileToConversationRunnable.java
index 1a9980e17..e7dde2f84 100644
--- a/src/main/java/de/pixart/messenger/services/AttachFileToConversationRunnable.java
+++ b/src/main/java/de/pixart/messenger/services/AttachFileToConversationRunnable.java
@@ -42,6 +42,10 @@ public class AttachFileToConversationRunnable implements Runnable, MediaTranscod
this.isVideoMessage = (mimeType != null && mimeType.startsWith("video/") && (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR2 || !getFileBackend().useFileAsIs(uri)));
}
+ public boolean isVideoMessage() {
+ return this.isVideoMessage;
+ }
+
private void processAsFile() {
final String path = mXmppConnectionService.getFileBackend().getOriginalPath(uri);
if (path != null) {
diff --git a/src/main/java/de/pixart/messenger/services/XmppConnectionService.java b/src/main/java/de/pixart/messenger/services/XmppConnectionService.java
index f011c67b1..519cec043 100644
--- a/src/main/java/de/pixart/messenger/services/XmppConnectionService.java
+++ b/src/main/java/de/pixart/messenger/services/XmppConnectionService.java
@@ -160,6 +160,7 @@ public class XmppConnectionService extends Service {
public static final String ACTION_GCM_MESSAGE_RECEIVED = "gcm_message_received";
private static final String ACTION_MERGE_PHONE_CONTACTS = "merge_phone_contacts";
private final SerialSingleThreadExecutor mFileAddingExecutor = new SerialSingleThreadExecutor();
+ private final SerialSingleThreadExecutor mVideoCompressionExecutor = new SerialSingleThreadExecutor();
private final SerialSingleThreadExecutor mDatabaseExecutor = new SerialSingleThreadExecutor();
private final IBinder mBinder = new XmppConnectionBinder();
private final List<Conversation> conversations = new CopyOnWriteArrayList<>();
@@ -493,8 +494,12 @@ public class XmppConnectionService extends Service {
}
message.setCounterpart(conversation.getNextCounterpart());
message.setType(Message.TYPE_FILE);
- AttachFileToConversationRunnable runnable = new AttachFileToConversationRunnable(this,uri,message,callback);
- mFileAddingExecutor.execute(runnable);
+ final AttachFileToConversationRunnable runnable = new AttachFileToConversationRunnable(this, uri, message, callback);
+ if (runnable.isVideoMessage()) {
+ mVideoCompressionExecutor.execute(runnable);
+ } else {
+ mFileAddingExecutor.execute(runnable);
+ }
}
public void attachImageToConversation(final Conversation conversation, final Uri uri, final UiCallback<Message> callback) {