Skip to content

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

How to valid it?

中文文档

Just create your own DownloadMgrInitialParams.InitCustomMaker and put those customized components to it, finally init the FileDownloader with it: FileDownloader#init

Step 1

Implementing your own customized component if you want. P.S: You can refer the default-impl.

Step 2

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*/));

Others

If you want to use okhttp as your connection component, the simplest way is this repo.

Clone this wiki locally