public class DownloadTaskHunter extends Object implements ITaskHunter, ITaskHunter.IStarter, ITaskHunter.IMessageHandler, BaseDownloadTask.LifeCycleCallback
ITaskHunter.IMessageHandler, ITaskHunter.IStarter| Modifier and Type | Method and Description |
|---|---|
boolean |
equalListener(FileDownloadListener listener) |
void |
free()
Free the current hunter.
|
Throwable |
getErrorCause() |
String |
getEtag() |
com.liulishuo.filedownloader.IFileDownloadMessenger |
getMessenger() |
int |
getRetryingTimes() |
long |
getSofarBytes() |
int |
getSpeed() |
byte |
getStatus() |
long |
getTotalBytes() |
void |
intoLaunchPool()
Enter into the launch pool.
|
boolean |
isLargeFile() |
boolean |
isResuming() |
boolean |
isReusedOldFile() |
void |
onBegin()
The task begin working.
|
void |
onIng()
The task is running, and during the downloading processing, when the status of the task
is changed will trigger to callback this method.
|
void |
onOver()
The task is end.
|
boolean |
pause() |
MessageSnapshot |
prepareErrorMessage(Throwable cause) |
void |
reset()
Reset the hunter.
|
void |
setMinIntervalUpdateSpeed(int minIntervalUpdateSpeed) |
void |
start()
Start the task in the launcher thread.
|
boolean |
updateKeepAhead(MessageSnapshot snapshot)
Try to dispatch the
snapshot with the keep ahead policy. |
boolean |
updateKeepFlow(MessageSnapshot snapshot)
Try to dispatch the
snapshot with the keep right flow policy. |
boolean |
updateMoreLikelyCompleted(MessageSnapshot snapshot)
Try to dispatch the
snapshot with the more likely completed policy. |
boolean |
updateSameFilePathTaskRunning(MessageSnapshot snapshot)
Try to dispatch the
snapshot with the same file path policy. |
public boolean updateKeepAhead(MessageSnapshot snapshot)
ITaskHunter.IMessageHandlersnapshot with the keep ahead policy.updateKeepAhead in interface ITaskHunter.IMessageHandlersnapshot - the received message snapshot.true the message has been dispatched successfully.public boolean updateKeepFlow(MessageSnapshot snapshot)
ITaskHunter.IMessageHandlersnapshot with the keep right flow policy.updateKeepFlow in interface ITaskHunter.IMessageHandlersnapshot - the received message snapshot.true the message has been dispatched successfully.public boolean updateMoreLikelyCompleted(MessageSnapshot snapshot)
ITaskHunter.IMessageHandlersnapshot with the more likely completed policy.
The more likely completed policy: in some case the snapshot more likely to a waiting to complete task.
updateMoreLikelyCompleted in interface ITaskHunter.IMessageHandlersnapshot - the received message snapshot.true the message has been dispatched successfully.public boolean updateSameFilePathTaskRunning(MessageSnapshot snapshot)
ITaskHunter.IMessageHandlersnapshot with the same file path policy.
The same file path policy: when the path provided by the user is a directory, we find the filename until the response from the service has been received, in this case when we find the target file path maybe can equal to another running task, so in this case, this task need callback a warn message.
updateSameFilePathTaskRunning in interface ITaskHunter.IMessageHandlersnapshot - the received message snapshot.true the message has been dispatched successfully.public com.liulishuo.filedownloader.IFileDownloadMessenger getMessenger()
getMessenger in interface ITaskHunter.IMessageHandlerpublic MessageSnapshot prepareErrorMessage(Throwable cause)
prepareErrorMessage in interface ITaskHunter.IMessageHandlercause - The cause of occurred exception.cause.public void onBegin()
BaseDownloadTask.LifeCycleCallbackonBegin in interface BaseDownloadTask.LifeCycleCallbackpublic void onIng()
BaseDownloadTask.LifeCycleCallbackonIng in interface BaseDownloadTask.LifeCycleCallbackpublic void onOver()
BaseDownloadTask.LifeCycleCallbackonOver in interface BaseDownloadTask.LifeCycleCallbackpublic void intoLaunchPool()
ITaskHunterintoLaunchPool in interface ITaskHunterFileDownloadTaskLauncherpublic boolean pause()
pause in interface ITaskHunterpublic byte getStatus()
getStatus in interface ITaskHunterFileDownloadStatuspublic void reset()
ITaskHunterreset in interface ITaskHunterpublic void setMinIntervalUpdateSpeed(int minIntervalUpdateSpeed)
setMinIntervalUpdateSpeed in interface IDownloadSpeed.LookupminIntervalUpdateSpeed - The minimum interval to update the speed, used to adjust
the refresh frequent.public int getSpeed()
getSpeed in interface IDownloadSpeed.Lookuppublic long getSofarBytes()
getSofarBytes in interface ITaskHunterpublic long getTotalBytes()
getTotalBytes in interface ITaskHunterpublic Throwable getErrorCause()
getErrorCause in interface ITaskHunterNull if has didn't occurred any error yet.public int getRetryingTimes()
getRetryingTimes in interface ITaskHunterpublic boolean isReusedOldFile()
isReusedOldFile in interface ITaskHuntertrue if didn't real start downloading but the old-file with target-path is
exist, and just reuse it. false otherwise.public boolean isResuming()
isResuming in interface ITaskHuntertrue if the currently downloading is the downloading resuming from the
breakpoint. false downloading from the beginning.public String getEtag()
getEtag in interface ITaskHunterpublic boolean isLargeFile()
isLargeFile in interface ITaskHuntertrue if the file length is large than 1.99G, false otherwise.public void free()
ITaskHunterfree in interface ITaskHunterpublic void start()
ITaskHunter.IStarterstart in interface ITaskHunter.IStarterpublic boolean equalListener(FileDownloadListener listener)
equalListener in interface ITaskHunter.IStarterlistener - The downloading listener.true if listener equal to the listener of the current task.