aboutsummaryrefslogtreecommitdiffstats
path: root/src/main
diff options
context:
space:
mode:
Diffstat (limited to 'src/main')
-rw-r--r--src/main/java/de/pixart/messenger/http/HttpDownloadConnection.java33
-rw-r--r--src/main/java/de/pixart/messenger/http/HttpUploadConnection.java6
-rw-r--r--src/main/java/de/pixart/messenger/services/XmppConnectionService.java2
3 files changed, 24 insertions, 17 deletions
diff --git a/src/main/java/de/pixart/messenger/http/HttpDownloadConnection.java b/src/main/java/de/pixart/messenger/http/HttpDownloadConnection.java
index 7d58cde07..7c056bdc1 100644
--- a/src/main/java/de/pixart/messenger/http/HttpDownloadConnection.java
+++ b/src/main/java/de/pixart/messenger/http/HttpDownloadConnection.java
@@ -344,22 +344,25 @@ public class HttpDownloadConnection implements Transferable {
@Override
public void run() {
- try {
- changeStatus(STATUS_DOWNLOADING);
- download();
- updateImageBounds();
- finish();
- } catch (SSLHandshakeException e) {
- changeStatus(STATUS_OFFER);
- } catch (Exception e) {
- if (interactive) {
- showToastForException(e);
- } else {
- HttpDownloadConnection.this.acceptedAutomatically = false;
- HttpDownloadConnection.this.mXmppConnectionService.getNotificationService().push(message);
+ changeStatus(STATUS_DOWNLOADING);
+ mXmppConnectionService.mDownloadExecutor.execute(() -> {
+ try {
+ changeStatus(STATUS_DOWNLOADING);
+ download();
+ updateImageBounds();
+ finish();
+ } catch (SSLHandshakeException e) {
+ changeStatus(STATUS_OFFER);
+ } catch (Exception e) {
+ if (interactive) {
+ showToastForException(e);
+ } else {
+ HttpDownloadConnection.this.acceptedAutomatically = false;
+ HttpDownloadConnection.this.mXmppConnectionService.getNotificationService().push(message);
+ }
+ cancel();
}
- cancel();
- }
+ });
}
private void download() throws Exception {
diff --git a/src/main/java/de/pixart/messenger/http/HttpUploadConnection.java b/src/main/java/de/pixart/messenger/http/HttpUploadConnection.java
index 04d56626d..f43a94d73 100644
--- a/src/main/java/de/pixart/messenger/http/HttpUploadConnection.java
+++ b/src/main/java/de/pixart/messenger/http/HttpUploadConnection.java
@@ -134,8 +134,10 @@ public class HttpUploadConnection implements Transferable {
@Override
public void success(SlotRequester.Slot slot) {
if (!cancelled) {
- HttpUploadConnection.this.slot = slot;
- new Thread(HttpUploadConnection.this::upload).start();
+ mXmppConnectionService.mUploadExecutor.execute(() -> {
+ HttpUploadConnection.this.slot = slot;
+ HttpUploadConnection.this.upload();
+ });
}
}
diff --git a/src/main/java/de/pixart/messenger/services/XmppConnectionService.java b/src/main/java/de/pixart/messenger/services/XmppConnectionService.java
index 6f67d7bc0..caa428092 100644
--- a/src/main/java/de/pixart/messenger/services/XmppConnectionService.java
+++ b/src/main/java/de/pixart/messenger/services/XmppConnectionService.java
@@ -199,6 +199,8 @@ public class XmppConnectionService extends Service {
private final SerialSingleThreadExecutor mDatabaseWriterExecutor = new SerialSingleThreadExecutor("DatabaseWriter");
private final SerialSingleThreadExecutor mDatabaseReaderExecutor = new SerialSingleThreadExecutor("DatabaseReader");
private final SerialSingleThreadExecutor mNotificationExecutor = new SerialSingleThreadExecutor("NotificationExecutor");
+ public final SerialSingleThreadExecutor mUploadExecutor = new SerialSingleThreadExecutor("FileUpload");
+ public final SerialSingleThreadExecutor mDownloadExecutor = new SerialSingleThreadExecutor("FileDownload");
private final ReplacingTaskManager mRosterSyncTaskManager = new ReplacingTaskManager();
private final IBinder mBinder = new XmppConnectionBinder();
private final List<Conversation> conversations = new CopyOnWriteArrayList<>();