main commit
Post-processing infrastructure * remove interfaces with one implementation * fix download resources with unknow length * marquee style for ProgressDrawable * "view details" option in mission context menu * notification for finished downloads * postprocessing infrastructure: sub-missions, circular file, layers for layers of abstractions for Java IO streams * Mp4 muxing (only DASH brand) * WebM muxing * Captions downloading * alert dialog for overwrite existing downloads finished or not. Misc changes * delete SQLiteDownloadDataSource.java * delete DownloadMissionSQLiteHelper.java * implement Localization from #114 Misc fixes (this branch) * restore old mission listeners variables. Prevents registered listeners get de-referenced on low-end devices * DownloadManagerService.checkForRunningMission() now return false if the mission has a error. * use Intent.FLAG_ACTIVITY_NEW_TASK when launching an activity from gigaget threads (apparently it is required in old versions of android) More changes * proper error handling "infrastructure" * queue instead of multiple downloads * move serialized pending downloads (.giga files) to app data * stop downloads when swicthing to mobile network (never works, see 2nd point) * save the thread count for next downloads * a lot of incoherences fixed * delete DownloadManagerTest.java (too many changes to keep this file updated)
This commit is contained in:
parent
45fea983b9
commit
5825843f68
48 changed files with 4379 additions and 1119 deletions
|
|
@ -0,0 +1,54 @@
|
|||
package us.shandian.giga.postprocessing;
|
||||
|
||||
import android.util.Log;
|
||||
|
||||
import org.schabi.newpipe.extractor.utils.io.SharpStream;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.Random;
|
||||
|
||||
import us.shandian.giga.get.DownloadMission;
|
||||
|
||||
/**
|
||||
* Algorithm for testing proposes
|
||||
*/
|
||||
class TestAlgo extends Postprocessing {
|
||||
|
||||
public TestAlgo(DownloadMission mission) {
|
||||
super(mission);
|
||||
|
||||
worksOnSameFile = true;
|
||||
recommendedReserve = 4096 * 1024;// 4 KiB
|
||||
}
|
||||
|
||||
@Override
|
||||
int process(SharpStream out, SharpStream... sources) throws IOException {
|
||||
|
||||
int written = 0;
|
||||
int size = 5 * 1024 * 1024;// 5 MiB
|
||||
byte[] buffer = new byte[8 * 1024];//8 KiB
|
||||
mission.length = size;
|
||||
|
||||
Random rnd = new Random();
|
||||
|
||||
// only write random data
|
||||
sources[0].dispose();
|
||||
|
||||
while (written < size) {
|
||||
rnd.nextBytes(buffer);
|
||||
|
||||
int read = Math.min(buffer.length, size - written);
|
||||
out.write(buffer, 0, read);
|
||||
|
||||
try {
|
||||
Thread.sleep((int) (Math.random() * 10));
|
||||
} catch (InterruptedException e) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
written += read;
|
||||
}
|
||||
|
||||
return Postprocessing.OK_RESULT;
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue