aboutsummaryrefslogtreecommitdiffstats
path: root/src/main/java/eu/siacs/conversations/http
diff options
context:
space:
mode:
authoriNPUTmice <daniel@gultsch.de>2014-11-14 01:29:56 +0100
committeriNPUTmice <daniel@gultsch.de>2014-11-15 15:34:12 +0100
commitc7acfe85c379b99c05cef98dbbab6f815b99ed83 (patch)
treebebb789d4f6edd18aae07495ec3fca477066b1d8 /src/main/java/eu/siacs/conversations/http
parentdac12be53e18962c80fd471421adac29b5c92f06 (diff)
progress for http images as well. fixed open button for sent files
Diffstat (limited to 'src/main/java/eu/siacs/conversations/http')
-rw-r--r--src/main/java/eu/siacs/conversations/http/HttpConnection.java15
1 files changed, 13 insertions, 2 deletions
diff --git a/src/main/java/eu/siacs/conversations/http/HttpConnection.java b/src/main/java/eu/siacs/conversations/http/HttpConnection.java
index 7ef81383..68c26c47 100644
--- a/src/main/java/eu/siacs/conversations/http/HttpConnection.java
+++ b/src/main/java/eu/siacs/conversations/http/HttpConnection.java
@@ -3,6 +3,7 @@ package eu.siacs.conversations.http;
import android.content.Intent;
import android.graphics.BitmapFactory;
import android.net.Uri;
+import android.os.SystemClock;
import org.apache.http.conn.ssl.StrictHostnameVerifier;
@@ -21,6 +22,7 @@ import javax.net.ssl.SSLContext;
import javax.net.ssl.SSLHandshakeException;
import javax.net.ssl.X509TrustManager;
+import eu.siacs.conversations.Config;
import eu.siacs.conversations.entities.Downloadable;
import eu.siacs.conversations.entities.DownloadableFile;
import eu.siacs.conversations.entities.Message;
@@ -38,6 +40,7 @@ public class HttpConnection implements Downloadable {
private int mStatus = Downloadable.STATUS_UNKNOWN;
private boolean acceptedAutomatically = false;
private int mProgress = 0;
+ private long mLastGuiRefresh = 0;
public HttpConnection(HttpConnectionManager manager) {
this.mHttpConnectionManager = manager;
@@ -243,7 +246,7 @@ public class HttpConnection implements Downloadable {
while ((count = is.read(buffer)) != -1) {
transmitted += count;
os.write(buffer, 0, count);
- mProgress = (int) (expected * 100 / transmitted);
+ updateProgress((int) ((((double) transmitted) / expected) * 100));
}
os.flush();
os.close();
@@ -252,12 +255,20 @@ public class HttpConnection implements Downloadable {
private void updateImageBounds() {
message.setType(Message.TYPE_IMAGE);
- mXmppConnectionService.getFileBackend().updateFileParams(message);
+ mXmppConnectionService.getFileBackend().updateFileParams(message,mUrl);
mXmppConnectionService.updateMessage(message);
}
}
+ public void updateProgress(int i) {
+ this.mProgress = i;
+ if (SystemClock.elapsedRealtime() - this.mLastGuiRefresh > Config.PROGRESS_UI_UPDATE_INTERVAL) {
+ this.mLastGuiRefresh = SystemClock.elapsedRealtime();
+ mXmppConnectionService.updateConversationUi();
+ }
+ }
+
@Override
public int getStatus() {
return this.mStatus;