Class DownloadJob
-
- All Implemented Interfaces:
public class DownloadJob
A task that can download a PDF document from a DownloadSource. You can create and start a job using startDownload. To monitor the download progress you can either set a listener using setProgressListener or retrieve a progress observable using getProgress.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description public abstract class
DownloadJob.ProgressListenerAdapter
An empty implementation of a ProgressListener.
public interface
DownloadJob.ProgressListener
Definition of callback objects for observing downloads.
-
Method Summary
Modifier and Type Method Description static DownloadJob
startDownload(@NonNull() DownloadRequest request)
Create a new DownloadJob from a DownloadRequest. File
getOutputFile()
Returns the output file as defined by the started DownloadRequest. void
cancel()
Cancel the running download. boolean
isComplete()
Returns true
if the download has been successfully completed.Flowable<Progress>
getProgress()
Returns an Observable that emits Progress events of the download. void
setProgressListener(@Nullable() DownloadJob.ProgressListener progressListener)
Sets a ProgressListener for monitoring the download. -
-
Method Detail
-
startDownload
static DownloadJob startDownload(@NonNull() DownloadRequest request)
Create a new DownloadJob from a DownloadRequest.
- Parameters:
request
- DownloadRequest that should be executed.- Returns:
An initialized and running DownloadJob based on the given
request
.
-
getOutputFile
File getOutputFile()
Returns the output file as defined by the started DownloadRequest.
- Returns:
File pointing to the download output.
-
cancel
void cancel()
Cancel the running download. Listeners won't receive a completion event after calling this method.
-
isComplete
boolean isComplete()
Returns
true
if the download has been successfully completed.- Returns:
true
if the download has been completed, otherwisefalse
.
-
getProgress
Flowable<Progress> getProgress()
Returns an Observable that emits Progress events of the download. When using this, make sure to properly handle back pressure.
- Returns:
A Observable emitting download Progress events.
-
setProgressListener
void setProgressListener(@Nullable() DownloadJob.ProgressListener progressListener)
Sets a ProgressListener for monitoring the download. Calling this method will replace any previously set listener. You may provide
null
to clear the listener.Note: Progress listener methods will be notified on the main thread.
- Parameters:
progressListener
- ProgressListener that should be notified, ornull
to clear the listener.
-
-
-
-