public class UrlConnectionDownloader extends Object implements Downloader
Downloader
which uses HttpURLConnection
to download images. A disk cache of 2%
of the total available space will be used (capped at 50MB) will automatically be installed in the
application's cache directory, when available.Downloader.Response, Downloader.ResponseException
Constructor and Description |
---|
UrlConnectionDownloader(android.content.Context context) |
Modifier and Type | Method and Description |
---|---|
Downloader.Response |
load(android.net.Uri uri,
int networkPolicy)
Download the specified image
url from the internet. |
protected HttpURLConnection |
openConnection(android.net.Uri path) |
void |
shutdown()
Allows to perform a clean up for this
Downloader including closing the disk cache and
other resources. |
public UrlConnectionDownloader(android.content.Context context)
protected HttpURLConnection openConnection(android.net.Uri path) throws IOException
IOException
public Downloader.Response load(android.net.Uri uri, int networkPolicy) throws IOException
Downloader
url
from the internet.load
in interface Downloader
uri
- Remote image URL.networkPolicy
- The NetworkPolicy
used for this request.Downloader.Response
containing either a Bitmap
representation of the request or an
InputStream
for the image data. null
can be returned to indicate a problem
loading the bitmap.IOException
- if the requested URL cannot successfully be loaded.public void shutdown()
Downloader
Downloader
including closing the disk cache and
other resources.shutdown
in interface Downloader
Copyright © 2013-2015 Square, Inc.. All Rights Reserved.