diff options
author | iNPUTmice <daniel@gultsch.de> | 2014-10-15 22:08:13 +0200 |
---|---|---|
committer | iNPUTmice <daniel@gultsch.de> | 2014-10-15 22:08:13 +0200 |
commit | f5019ba96647bd1c33153e6e9099d21dcf47bfa7 (patch) | |
tree | 5791e6832d3ad617f6e4a3fa3a6761a97d3dee8c /src/eu/siacs/conversations/http | |
parent | 89cc4d12477e4c5593d10b69e0ed42cbaedfb190 (diff) |
detect deleted files on start up. got rid of lagecy image provider for performance reasons. NOTE: this will prevent you to access images older than version 0.6
Diffstat (limited to '')
-rw-r--r-- | src/eu/siacs/conversations/http/HttpConnection.java | 23 | ||||
-rw-r--r-- | src/eu/siacs/conversations/http/HttpConnectionManager.java | 8 |
2 files changed, 10 insertions, 21 deletions
diff --git a/src/eu/siacs/conversations/http/HttpConnection.java b/src/eu/siacs/conversations/http/HttpConnection.java index c53b9fd54..340364120 100644 --- a/src/eu/siacs/conversations/http/HttpConnection.java +++ b/src/eu/siacs/conversations/http/HttpConnection.java @@ -9,7 +9,9 @@ import java.net.URL; import javax.net.ssl.HttpsURLConnection; +import android.content.Intent; import android.graphics.BitmapFactory; +import android.net.Uri; import eu.siacs.conversations.entities.Downloadable; import eu.siacs.conversations.entities.DownloadableFile; @@ -24,8 +26,8 @@ public class HttpConnection implements Downloadable { private URL mUrl; private Message message; private DownloadableFile file; - private long mPreviousFileSize = 0; private int mStatus = Downloadable.STATUS_UNKNOWN; + private boolean mAutostart = true; public HttpConnection(HttpConnectionManager manager) { this.mHttpConnectionManager = manager; @@ -44,23 +46,14 @@ public class HttpConnection implements Downloadable { try { mUrl = new URL(message.getBody()); this.file = mXmppConnectionService.getFileBackend() - .getConversationsFile(message, false); + .getFile(message, false); + this.mAutostart = true; checkFileSize(); } catch (MalformedURLException e) { this.cancel(); } } - public void init(Message message, URL url) { - this.message = message; - this.message.setDownloadable(this); - this.mUrl = url; - this.file = mXmppConnectionService.getFileBackend() - .getConversationsFile(message, false); - this.mPreviousFileSize = message.getImageParams().size; - checkFileSize(); - } - private void checkFileSize() { changeStatus(STATUS_CHECKING); new Thread(new FileSizeChecker()).start(); @@ -74,6 +67,9 @@ public class HttpConnection implements Downloadable { } private void finish() { + Intent intent = new Intent(Intent.ACTION_MEDIA_SCANNER_SCAN_FILE); + intent.setData(Uri.fromFile(file)); + mXmppConnectionService.sendBroadcast(intent); message.setDownloadable(null); mHttpConnectionManager.finishConnection(this); } @@ -96,8 +92,7 @@ public class HttpConnection implements Downloadable { } file.setExpectedSize(size); message.setType(Message.TYPE_IMAGE); - if (size <= mHttpConnectionManager.getAutoAcceptFileSize() - || size == mPreviousFileSize) { + if (size <= mHttpConnectionManager.getAutoAcceptFileSize() && mAutostart) { start(); } else { changeStatus(STATUS_OFFER); diff --git a/src/eu/siacs/conversations/http/HttpConnectionManager.java b/src/eu/siacs/conversations/http/HttpConnectionManager.java index 011ecc3f5..ff71d45c4 100644 --- a/src/eu/siacs/conversations/http/HttpConnectionManager.java +++ b/src/eu/siacs/conversations/http/HttpConnectionManager.java @@ -5,6 +5,7 @@ import java.util.List; import java.util.concurrent.CopyOnWriteArrayList; import eu.siacs.conversations.entities.Message; +import eu.siacs.conversations.entities.Message.ImageParams; import eu.siacs.conversations.services.AbstractConnectionManager; import eu.siacs.conversations.services.XmppConnectionService; @@ -23,13 +24,6 @@ public class HttpConnectionManager extends AbstractConnectionManager { return connection; } - public HttpConnection createNewConnection(Message message, URL url) { - HttpConnection connection = new HttpConnection(this); - connection.init(message, url); - this.connections.add(connection); - return connection; - } - public void finishConnection(HttpConnection connection) { this.connections.remove(connection); } |