and more fixes

* fix content length reading
* use float overflow. Expensive, double is used instead
* fix invalid cast after click the mission body
* use a list for maximum attemps (downloads)
* minor clean up (DownloadManager.java)
* dont pass SharedPreferences instace to DownloadManager
* use a switch instead of checkbox for cross_network_downloads
* notify media scanner after deleting a finished download
This commit is contained in:
kapodamy 2018-11-24 00:14:37 -03:00
parent d647555e3a
commit f3d4d4747a
12 changed files with 111 additions and 52 deletions

View file

@ -35,7 +35,9 @@ public class DownloadInitializer implements Runnable {
HttpURLConnection conn = mMission.openConnection(mId, -1, -1);
if (!mMission.running || Thread.interrupted()) return;
mMission.length = conn.getContentLength();
mMission.length = Utility.getContentLength(conn);
if (mMission.length == 0) {
mMission.notifyError(DownloadMission.ERROR_HTTP_NO_CONTENT, null);
return;
@ -97,7 +99,7 @@ public class DownloadInitializer implements Runnable {
for (long i = 0; i < mMission.currentThreadCount; i++) {
mMission.threadBlockPositions.add(i);
mMission.threadBytePositions.add(0);
mMission.threadBytePositions.add(0L);
}
File file;