public class

DownloadJob

extends Object
java.lang.Object
   ↳ com.pspdfkit.document.download.DownloadJob

Class Overview

A task that can download a PDF document from a DownloadSource. You can create and start a job using startDownload(DownloadRequest). To monitor the download progress you can either set a listener using setProgressListener(ProgressListener) or retrieve a progress observable using getProgress().

Summary

Nested Classes
interface DownloadJob.ProgressListener Definition of callback objects for observing downloads. 
class DownloadJob.ProgressListenerAdapter An empty implementation of a DownloadJob.ProgressListener
Public Methods
void cancel()
Cancel the running download.
File getOutputFile()
Returns the output file as defined by the started DownloadRequest.
Flowable<Progress> getProgress()
Returns an Observable that emits Progress events of the download.
boolean isComplete()
Returns true if the download has been successfully completed.
void setProgressListener(DownloadJob.ProgressListener progressListener)
Sets a DownloadJob.ProgressListener for monitoring the download.
static DownloadJob startDownload(DownloadRequest request)
Create a new DownloadJob from a DownloadRequest.
[Expand]
Inherited Methods
From class java.lang.Object

Public Methods

public void cancel ()

Cancel the running download. Listeners won't receive a completion event after calling this method.

public File getOutputFile ()

Returns the output file as defined by the started DownloadRequest.

Returns
  • File pointing to the download output.

public Flowable<Progress> getProgress ()

Returns an Observable that emits Progress events of the download. When using this, make sure to properly handle back pressure.

Returns

public boolean isComplete ()

Returns true if the download has been successfully completed.

Returns
  • true if the download has been completed, otherwise false.

public void setProgressListener (DownloadJob.ProgressListener progressListener)

Sets a DownloadJob.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 DownloadJob.ProgressListener that should be notified, or null to clear the listener.

public static DownloadJob startDownload (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.