-
Notifications
You must be signed in to change notification settings - Fork 2.2k
Customizable Component
Jacksgong edited this page Jun 4, 2017
·
7 revisions
From now on, FileDownloader support following components to be customized by yourself:
| Name | Interface | Default Impl |
|---|---|---|
| Connection | FileDownloadConnection | FileDownloadUrlConnection |
| OutputStream | FileDownloadOutputStream | FileDownloadRandomAccessFile |
| Database | FileDownloadDatabase | DefaultDatabaseImpl |
| ConnectionCountAdapter | ConnectionCountAdapter | DefaultConnectionCountAdapter |
The default connection count strategy for each task, you can customize it through ConnectionCountAdapter:
- one connection: file length [0, 1MB)
- two connections: file length [1MB, 5MB)
- three connections: file length [5MB, 50MB)
- four connections: file length [50MB, 100MB)
- five connections: file length [100MB, -)
Just create your own DownloadMgrInitialParams.InitCustomMaker and put those customized components to it, finally init the FileDownloader with it: FileDownloader#init
Implementing your own customized component if you want. P.S: You can refer the default-impl.
Putting it into FileDownloader when you init the FileDownloader:
FileDownloader.init(getApplicationContext(), new DownloadMgrInitialParams.InitCustomMaker()
.database(/*You can put your customized database component here*/)
.outputStreamCreator(/*You can put your customized output-stream component here*/)
.connectionCreator(/*You can put your customized connection component here*/));If you want to use okhttp as your connection component, the simplest way is this repo.
- Initialization
- Start downloading
- Pause or Stop
- Get the internal stored data
- Customizable Component
- Interface