code cleanup
* migrate few annotations to androidx * mission recovery: better error handling (except StreamExtractor.getErrorMessage() method always returns an error) * post-processing: more detailed progress [file specific changes] DownloadMission.java * remove redundant/boilerplate code (again) * make few variables volatile * better file "length" approximation * use "done" variable to count the amount of bytes downloaded (simplify percent calc in UI code) Postprocessing.java * if case of error use "ERROR_POSTPROCESSING" instead of "ERROR_UNKNOWN_EXCEPTION" * simplify source stream init DownloadManager.java * move all "service message sending" code to DownloadMission * remove not implemented method "notifyUserPendingDownloads()" also his unused strings DownloadManagerService.java * use START_STICKY instead of START_NOT_STICKY * simplify addMissionEventListener()/removeMissionEventListener() methods (always are called from the main thread) Deleter.java * better method definition MissionAdapter.java * better method definition * code cleanup * the UI is now refreshed every 750ms * simplify download progress calculation * indicates if the download is actually recovering * smooth download speed measure * show estimated remain time MainFragment.java: * check if viewPager is null (issued by "Apply changes" feature of Android Studio)
This commit is contained in:
parent
763995d4c9
commit
e6d9d8e26d
53 changed files with 554 additions and 622 deletions
|
|
@ -87,6 +87,7 @@ public class DownloadRunnable extends Thread {
|
|||
if (mConn.getResponseCode() == 416) {
|
||||
if (block.done > 0) {
|
||||
// try again from the start (of the block)
|
||||
mMission.notifyProgress(-block.done);
|
||||
block.done = 0;
|
||||
retry = true;
|
||||
mConn.disconnect();
|
||||
|
|
@ -114,7 +115,7 @@ public class DownloadRunnable extends Thread {
|
|||
int len;
|
||||
|
||||
// use always start <= end
|
||||
// fixes a deadlock in DownloadRunnable because youtube is sending one byte alone after downloading 26MiB exactly
|
||||
// fixes a deadlock because in some videos, youtube is sending one byte alone
|
||||
while (start <= end && mMission.running && (len = is.read(buf, 0, buf.length)) != -1) {
|
||||
f.write(buf, 0, len);
|
||||
start += len;
|
||||
|
|
@ -135,7 +136,7 @@ public class DownloadRunnable extends Thread {
|
|||
|
||||
if (mId == 1) {
|
||||
// only the first thread will execute the recovery procedure
|
||||
mMission.doRecover(e);
|
||||
mMission.doRecover(ERROR_HTTP_FORBIDDEN);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue