public final class ProgressiveDownloader extends java.lang.Object implements Downloader
Downloader.ProgressListener| Constructor and Description |
|---|
ProgressiveDownloader(java.lang.String uri,
java.lang.String customCacheKey,
DownloaderConstructorHelper constructorHelper) |
| Modifier and Type | Method and Description |
|---|---|
void |
download(Downloader.ProgressListener listener)
Downloads the media.
|
long |
getDownloadedBytes()
Returns the total number of downloaded bytes, or
C.LENGTH_UNSET if it hasn't been
calculated yet. |
float |
getDownloadPercentage()
Returns the download percentage, or
Float.NaN if it can't be calculated yet. |
void |
init()
Initializes the downloader.
|
void |
remove()
Removes all of the downloaded data of the media.
|
public ProgressiveDownloader(java.lang.String uri,
java.lang.String customCacheKey,
DownloaderConstructorHelper constructorHelper)
uri - Uri of the data to be downloaded.customCacheKey - A custom key that uniquely identifies the original stream. Used for cache
indexing. May be null.constructorHelper - a DownloaderConstructorHelper instance.public void init()
Downloaderinit in interface DownloaderDownloader.getDownloadedBytes(),
Downloader.getDownloadPercentage()public void download(@Nullable
Downloader.ProgressListener listener)
throws java.lang.InterruptedException,
java.io.IOException
Downloaderdownload in interface Downloaderlistener - If not null, called during download.java.lang.InterruptedException - If the thread has been interrupted.DownloadException - Thrown if the media cannot be downloaded.java.io.IOException - Thrown when there is an io error while downloading.public void remove()
Downloaderremove in interface Downloaderpublic long getDownloadedBytes()
DownloaderC.LENGTH_UNSET if it hasn't been
calculated yet.getDownloadedBytes in interface DownloaderDownloader.init()public float getDownloadPercentage()
DownloaderFloat.NaN if it can't be calculated yet. This
value can be an estimation.getDownloadPercentage in interface DownloaderDownloader.init()