public class BaseImageDownloader extends java.lang.Object implements ImageDownloader
InputStream
of image by URI from network or file system or app resources.URLConnection
is used to retrieve image stream from network.ImageDownloader.Scheme
Modifier and Type | Field and Description |
---|---|
protected static java.lang.String |
ALLOWED_URI_CHARS
"@#&=*+-_.,:!?()/~\'%"
|
protected static int |
BUFFER_SIZE
32768
|
protected int |
connectTimeout |
protected static java.lang.String |
CONTENT_CONTACTS_URI_PREFIX |
protected android.content.Context |
context |
static int |
DEFAULT_HTTP_CONNECT_TIMEOUT
5000
|
static int |
DEFAULT_HTTP_READ_TIMEOUT
20000
|
protected static int |
MAX_REDIRECT_COUNT |
protected int |
readTimeout |
Constructor and Description |
---|
BaseImageDownloader(android.content.Context context) |
BaseImageDownloader(android.content.Context context,
int connectTimeout,
int readTimeout) |
Modifier and Type | Method and Description |
---|---|
protected java.net.HttpURLConnection |
createConnection(java.lang.String url,
java.lang.Object extra)
Create HTTP connection for incoming URL
|
protected java.io.InputStream |
getContactPhotoStream(android.net.Uri uri) |
java.io.InputStream |
getStream(java.lang.String imageUri,
java.lang.Object extra)
Retrieves
InputStream of image by URI. |
protected java.io.InputStream |
getStreamFromAssets(java.lang.String imageUri,
java.lang.Object extra)
Retrieves
InputStream of image by URI (image is located in assets of application). |
protected java.io.InputStream |
getStreamFromContent(java.lang.String imageUri,
java.lang.Object extra)
Retrieves
InputStream of image by URI (image is accessed using ContentResolver ). |
protected java.io.InputStream |
getStreamFromDrawable(java.lang.String imageUri,
java.lang.Object extra)
Retrieves
InputStream of image by URI (image is located in drawable resources of application). |
protected java.io.InputStream |
getStreamFromFile(java.lang.String imageUri,
java.lang.Object extra)
Retrieves
InputStream of image by URI (image is located on the local file system or SD card). |
protected java.io.InputStream |
getStreamFromNetwork(java.lang.String imageUri,
java.lang.Object extra)
Retrieves
InputStream of image by URI (image is located in the network). |
protected java.io.InputStream |
getStreamFromOtherSource(java.lang.String imageUri,
java.lang.Object extra)
Retrieves
InputStream of image by URI from other source with unsupported scheme. |
protected boolean |
shouldBeProcessed(java.net.HttpURLConnection conn) |
public static final int DEFAULT_HTTP_CONNECT_TIMEOUT
public static final int DEFAULT_HTTP_READ_TIMEOUT
protected static final int BUFFER_SIZE
protected static final java.lang.String ALLOWED_URI_CHARS
protected static final int MAX_REDIRECT_COUNT
protected static final java.lang.String CONTENT_CONTACTS_URI_PREFIX
protected final android.content.Context context
protected final int connectTimeout
protected final int readTimeout
public BaseImageDownloader(android.content.Context context)
public BaseImageDownloader(android.content.Context context, int connectTimeout, int readTimeout)
public java.io.InputStream getStream(java.lang.String imageUri, java.lang.Object extra) throws java.io.IOException
ImageDownloader
InputStream
of image by URI.getStream
in interface ImageDownloader
imageUri
- Image URIextra
- Auxiliary object which was passed to DisplayImageOptions.extraForDownloader(Object)
; can be nullInputStream
of imagejava.io.IOException
- if some I/O error occurs during getting image streamprotected java.io.InputStream getStreamFromNetwork(java.lang.String imageUri, java.lang.Object extra) throws java.io.IOException
InputStream
of image by URI (image is located in the network).imageUri
- Image URIextra
- Auxiliary object which was passed to DisplayImageOptions.extraForDownloader(Object)
; can be nullInputStream
of imagejava.io.IOException
- if some I/O error occurs during network request or if no InputStream could be created for
URL.protected boolean shouldBeProcessed(java.net.HttpURLConnection conn) throws java.io.IOException
conn
- Opened request connection (response code is available)java.io.IOException
protected java.net.HttpURLConnection createConnection(java.lang.String url, java.lang.Object extra) throws java.io.IOException
url
- URL to connect toextra
- Auxiliary object which was passed to DisplayImageOptions.extraForDownloader(Object)
; can be nulljava.io.IOException
- if some I/O error occurs during network request or if no InputStream could be created for
URL.protected java.io.InputStream getStreamFromFile(java.lang.String imageUri, java.lang.Object extra) throws java.io.IOException
InputStream
of image by URI (image is located on the local file system or SD card).imageUri
- Image URIextra
- Auxiliary object which was passed to DisplayImageOptions.extraForDownloader(Object)
; can be nullInputStream
of imagejava.io.IOException
- if some I/O error occurs reading from file systemprotected java.io.InputStream getStreamFromContent(java.lang.String imageUri, java.lang.Object extra) throws java.io.FileNotFoundException
InputStream
of image by URI (image is accessed using ContentResolver
).imageUri
- Image URIextra
- Auxiliary object which was passed to DisplayImageOptions.extraForDownloader(Object)
; can be nullInputStream
of imagejava.io.FileNotFoundException
- if the provided URI could not be openedprotected java.io.InputStream getContactPhotoStream(android.net.Uri uri)
protected java.io.InputStream getStreamFromAssets(java.lang.String imageUri, java.lang.Object extra) throws java.io.IOException
InputStream
of image by URI (image is located in assets of application).imageUri
- Image URIextra
- Auxiliary object which was passed to DisplayImageOptions.extraForDownloader(Object)
; can be nullInputStream
of imagejava.io.IOException
- if some I/O error occurs file readingprotected java.io.InputStream getStreamFromDrawable(java.lang.String imageUri, java.lang.Object extra)
InputStream
of image by URI (image is located in drawable resources of application).imageUri
- Image URIextra
- Auxiliary object which was passed to DisplayImageOptions.extraForDownloader(Object)
; can be nullInputStream
of imageprotected java.io.InputStream getStreamFromOtherSource(java.lang.String imageUri, java.lang.Object extra) throws java.io.IOException
InputStream
of image by URI from other source with unsupported scheme. Should be overriden by
successors to implement image downloading from special sources.UnsupportedOperationException
by
default.imageUri
- Image URIextra
- Auxiliary object which was passed to DisplayImageOptions.extraForDownloader(Object)
; can be nullInputStream
of imagejava.io.IOException
- if some I/O error occursjava.lang.UnsupportedOperationException
- if image URI has unsupported scheme(protocol)