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/HttpConnection.java | |
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 'src/eu/siacs/conversations/http/HttpConnection.java')
-rw-r--r-- | src/eu/siacs/conversations/http/HttpConnection.java | 23 |
1 files changed, 9 insertions, 14 deletions
diff --git a/src/eu/siacs/conversations/http/HttpConnection.java b/src/eu/siacs/conversations/http/HttpConnection.java index c53b9fd5..34036412 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); |