-
Notifications
You must be signed in to change notification settings - Fork 2.2k
BaseDownloadTask
Jacksgong edited this page Apr 18, 2016
·
12 revisions
For example:
FileDownloader.create(URL).setPath(xxx).setListener(xxx).start()
function | description |
---|---|
setPath(path:String) | Absolute path for save the download file |
setListener(listener:FileDownloadListener) | For callback download status(pending,connected,progress,blockComplete,retry,error,paused,completed,warn) |
setCallbackProgressTimes(times:int) | Set maximal callback times on callback FileDownloadListener#progress
|
setTag(tag:Object) | Sets the tag associated with this task, not be used by internal |
setTag(key:int, tag:Object) | Sets a tag associated with this task. If the key already existed, the old tag will be replaced |
setForceReDownload(isForceReDownload:boolean) | If set to true, will not check whether the file is downloaded by past, default false |
setFinishListener(listener:FinishListener) | - |
setAutoRetryTimes(autoRetryTimes:int) | Set the number of times to automatically retry when encounter any error, default 0 |
setSyncCallback(syncCallback:boolean) | if true will invoke callbacks of FileDownloadListener directly on the download thread(do not post the message to the ui thread), default false |
addHeader(name:String, values:String) | Add custom request header to the task. Attention: We have already handled ETag, and will add If-Match & Range value if it works |
addHeader(line:String) | Add custom request header to the task. Attention: We have already handled ETag, and will add If-Match & Range value if it works |
removeAllHeaders(name:String) | Remove all custom request header bind with the {name}
|
setMinIntervalUpdateSpeed(minIntervalUpdateSpeedMs:int) | The min interval millisecond for updating the download speed in downloading process(Status equal to progress). Default 5 ms. If less than or equal to 0, will not calculate the download speed in process |
ready(void) | Ready task( For queue task ) |
start(void) | Start task |
pause(void) | Pause task |
getDownloadId(void):int | Get download id (generate by url & path) |
getUrl(void):String | Get download url |
getCallbackProgressTimes(void):int | Get maximal callback times on callback FileDownloadListener#progress
|
getPath(void):String | Get absolute path for save the download file |
getListener(void):FileDownloadListener | Get current listener |
getSoFarBytes(void):int | Get already downloaded bytes |
getTotalBytes(void):int | Get file total bytes |
getStatus(void):int | Get current status |
isForceReDownload(void):boolean | Force re-download,do not care about whether already downloaded or not |
getEx(void):Throwable | Get throwable |
isReusedOldFile(void):boolean | Is reused downloaded old file |
getTag(void):Object | Get the task's tag |
getTag(key:int):Object | Get the object stored in the task as a tag, or null if not set. |
isContinue(void):boolean | Is resume by breakpoint |
getEtag(void):String | Get current ETag on header |
getAutoRetryTimes(void):int | Get the number of times to automatically retry |
getRetryingTimes(void):int | Get the current number of retry |
isSyncCallback(void):boolean | Whether sync invoke callbacks of FileDownloadListener directly on the download thread |
getSpeed(void):int | Get the download speed for a task. If it is in processing, the speed would be real-time speed; If finished, the speed would be average speed. Unit: KB/s |
- Initialization
- Start downloading
- Pause or Stop
- Get the internal stored data
- Customizable Component
- Interface