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:
parent
d647555e3a
commit
f3d4d4747a
12 changed files with 111 additions and 52 deletions
|
|
@ -1,5 +1,6 @@
|
|||
package us.shandian.giga.get;
|
||||
|
||||
import android.annotation.SuppressLint;
|
||||
import android.support.annotation.NonNull;
|
||||
import android.util.Log;
|
||||
|
||||
|
|
@ -10,9 +11,13 @@ import java.net.HttpURLConnection;
|
|||
import java.nio.channels.ClosedByInterruptException;
|
||||
|
||||
|
||||
import us.shandian.giga.util.Utility;
|
||||
|
||||
import static org.schabi.newpipe.BuildConfig.DEBUG;
|
||||
|
||||
// Single-threaded fallback mode
|
||||
/**
|
||||
* Single-threaded fallback mode
|
||||
*/
|
||||
public class DownloadRunnableFallback implements Runnable {
|
||||
private static final String TAG = "DownloadRunnableFallback";
|
||||
|
||||
|
|
@ -43,10 +48,11 @@ public class DownloadRunnableFallback implements Runnable {
|
|||
}
|
||||
|
||||
@Override
|
||||
@SuppressLint("LongLogTag")
|
||||
public void run() {
|
||||
boolean done;
|
||||
|
||||
int start = 0;
|
||||
long start = 0;
|
||||
|
||||
if (!mMission.unknownLength) {
|
||||
start = mMission.getBlockBytePosition(0);
|
||||
|
|
@ -56,11 +62,12 @@ public class DownloadRunnableFallback implements Runnable {
|
|||
}
|
||||
|
||||
try {
|
||||
int rangeStart = (mMission.unknownLength || start < 1) ? -1 : start;
|
||||
long rangeStart = (mMission.unknownLength || start < 1) ? -1 : start;
|
||||
HttpURLConnection conn = mMission.openConnection(1, rangeStart, -1);
|
||||
|
||||
// secondary check for the file length
|
||||
if (!mMission.unknownLength) mMission.unknownLength = conn.getContentLength() == -1;
|
||||
if (!mMission.unknownLength)
|
||||
mMission.unknownLength = Utility.getContentLength(conn) == -1;
|
||||
|
||||
f = new RandomAccessFile(mMission.getDownloadedFile(), "rw");
|
||||
f.seek(mMission.offsets[mMission.current] + start);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue