public class OkHttpDownloader extends Object implements Downloader
Downloader
which uses OkHttp to download images.Downloader.Response, Downloader.ResponseException
Constructor and Description |
---|
OkHttpDownloader(android.content.Context context)
Create new downloader that uses OkHttp.
|
OkHttpDownloader(android.content.Context context,
long maxSize)
Create new downloader that uses OkHttp.
|
OkHttpDownloader(File cacheDir)
Create new downloader that uses OkHttp.
|
OkHttpDownloader(File cacheDir,
long maxSize)
Create new downloader that uses OkHttp.
|
OkHttpDownloader(com.squareup.okhttp.OkHttpClient client)
Create a new downloader that uses the specified OkHttp instance.
|
Modifier and Type | Method and Description |
---|---|
protected com.squareup.okhttp.OkHttpClient |
getClient() |
Downloader.Response |
load(android.net.Uri uri,
int networkPolicy)
Download the specified image
url from the internet. |
void |
shutdown()
Allows to perform a clean up for this
Downloader including closing the disk cache and
other resources. |
public OkHttpDownloader(android.content.Context context)
public OkHttpDownloader(File cacheDir)
cacheDir
- The directory in which the cache should be storedpublic OkHttpDownloader(android.content.Context context, long maxSize)
maxSize
- The size limit for the cache.public OkHttpDownloader(File cacheDir, long maxSize)
cacheDir
- The directory in which the cache should be storedmaxSize
- The size limit for the cache.public OkHttpDownloader(com.squareup.okhttp.OkHttpClient client)
protected final com.squareup.okhttp.OkHttpClient getClient()
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.