public class ImageLoader extends Object
ImageViews
init(ImageLoaderConfiguration)
method must be called before any other method.限定符 | 构造器和说明 |
---|---|
protected |
ImageLoader() |
限定符和类型 | 方法和说明 | ||
---|---|---|---|
void |
cancelDisplayTask(ImageAware imageAware)
Cancel the task of loading and displaying image for passed
ImageAware . |
||
void |
cancelDisplayTask(android.widget.ImageView imageView)
Cancel the task of loading and displaying image for passed
ImageView . |
||
void |
clearDiscCache()
已过时。
Use
clearDiskCache() instead |
||
void |
clearDiskCache()
Clears disk cache.
|
||
void |
clearMemoryCache()
Clears memory cache
|
||
void |
denyNetworkDownloads(boolean denyNetworkDownloads)
Denies or allows ImageLoader to download images from the network.
|
||
void |
destroy()
Stops ImageLoader and clears current configuration.
|
||
void |
displayImage(String uri,
ImageAware imageAware)
Adds display image task to execution pool.
|
||
void |
displayImage(String uri,
ImageAware imageAware,
DisplayImageOptions options)
Adds display image task to execution pool.
|
||
void |
displayImage(String uri,
ImageAware imageAware,
DisplayImageOptions options,
ImageLoadingListener listener)
Adds display image task to execution pool.
|
||
void |
displayImage(String uri,
ImageAware imageAware,
DisplayImageOptions options,
ImageLoadingListener listener,
ImageLoadingProgressListener progressListener)
Adds display image task to execution pool.
|
||
void |
displayImage(String uri,
ImageAware imageAware,
DisplayImageOptions options,
ImageSize targetSize,
ImageLoadingListener listener,
ImageLoadingProgressListener progressListener)
Adds display image task to execution pool.
|
||
void |
displayImage(String uri,
ImageAware imageAware,
ImageLoadingListener listener)
Adds display image task to execution pool.
|
||
void |
displayImage(String uri,
android.widget.ImageView imageView)
Adds display image task to execution pool.
|
||
void |
displayImage(String uri,
android.widget.ImageView imageView,
DisplayImageOptions options)
Adds display image task to execution pool.
|
||
void |
displayImage(String uri,
android.widget.ImageView imageView,
DisplayImageOptions options,
ImageLoadingListener listener)
Adds display image task to execution pool.
|
||
void |
displayImage(String uri,
android.widget.ImageView imageView,
DisplayImageOptions options,
ImageLoadingListener listener,
ImageLoadingProgressListener progressListener)
Adds display image task to execution pool.
|
||
void |
displayImage(String uri,
android.widget.ImageView imageView,
ImageLoadingListener listener)
Adds display image task to execution pool.
|
||
void |
displayImage(String uri,
android.widget.ImageView imageView,
ImageSize targetImageSize)
Adds display image task to execution pool.
|
||
DiskCache |
getDiscCache()
已过时。
Use
getDiskCache() instead |
||
DiskCache |
getDiskCache()
Returns disk cache
|
||
static ImageLoader |
getInstance()
Returns singleton class instance
|
||
String |
getLoadingUriForView(ImageAware imageAware)
Returns URI of image which is loading at this moment into passed
ImageAware |
||
String |
getLoadingUriForView(android.widget.ImageView imageView)
Returns URI of image which is loading at this moment into passed
ImageView |
||
MemoryCache |
getMemoryCache()
Returns memory cache
|
||
void |
handleSlowNetwork(boolean handleSlowNetwork)
Sets option whether ImageLoader will use FlushedInputStream for network downloads to handle
void init(ImageLoaderConfiguration configuration)
Initializes ImageLoader instance with configuration.
| ||
boolean |
isInited()
Returns true - if ImageLoader is initialized with
configuration; false - otherwise
|
||
void |
loadImage(String uri,
DisplayImageOptions options,
ImageLoadingListener listener)
Adds load image task to execution pool.
|
||
void |
loadImage(String uri,
ImageLoadingListener listener)
Adds load image task to execution pool.
|
||
void |
loadImage(String uri,
ImageSize targetImageSize,
DisplayImageOptions options,
ImageLoadingListener listener)
Adds load image task to execution pool.
|
||
void |
loadImage(String uri,
ImageSize targetImageSize,
DisplayImageOptions options,
ImageLoadingListener listener,
ImageLoadingProgressListener progressListener)
Adds load image task to execution pool.
|
||
void |
loadImage(String uri,
ImageSize targetImageSize,
ImageLoadingListener listener)
Adds load image task to execution pool.
|
||
android.graphics.Bitmap |
loadImageSync(String uri)
Loads and decodes image synchronously.
|
||
android.graphics.Bitmap |
loadImageSync(String uri,
DisplayImageOptions options)
Loads and decodes image synchronously.
|
||
android.graphics.Bitmap |
loadImageSync(String uri,
ImageSize targetImageSize)
Loads and decodes image synchronously.
|
||
android.graphics.Bitmap |
loadImageSync(String uri,
ImageSize targetImageSize,
DisplayImageOptions options)
Loads and decodes image synchronously.
|
||
void |
pause()
Pause ImageLoader.
|
||
void |
resume()
Resumes waiting "load&display" tasks
|
||
void |
setDefaultLoadingListener(ImageLoadingListener listener)
Sets a default loading listener for all display and loading tasks.
|
||
void |
stop()
Cancels all running and scheduled display image tasks.
|
public static final String TAG
public static ImageLoader getInstance()
public void init(ImageLoaderConfiguration configuration)
isInited()
== true) then this method does nothing.configuration
- ImageLoader configurationIllegalArgumentException
- if configuration parameter is nullpublic boolean isInited()
public void displayImage(String uri, ImageAware imageAware)
init(ImageLoaderConfiguration)
method must be called before this method calluri
- Image URI (i.e. "http://site.com/image.png", "file:///mnt/sdcard/image.png")imageAware
- Image aware view
which should display imageIllegalStateException
- if init(ImageLoaderConfiguration)
method wasn't called beforeIllegalArgumentException
- if passed imageAware is nullpublic void displayImage(String uri, ImageAware imageAware, ImageLoadingListener listener)
init(ImageLoaderConfiguration)
method must be called before this method calluri
- Image URI (i.e. "http://site.com/image.png", "file:///mnt/sdcard/image.png")imageAware
- Image aware view
which should display imagelistener
- Listener for image loading process. Listener fires events on
UI thread if this method is called on UI thread.IllegalStateException
- if init(ImageLoaderConfiguration)
method wasn't called beforeIllegalArgumentException
- if passed imageAware is nullpublic void displayImage(String uri, ImageAware imageAware, DisplayImageOptions options)
init(ImageLoaderConfiguration)
method must be called before this method calluri
- Image URI (i.e. "http://site.com/image.png", "file:///mnt/sdcard/image.png")imageAware
- Image aware view
which should display imageoptions
- Options for image
decoding and displaying. If null - default display image options
from configuration will be used.IllegalStateException
- if init(ImageLoaderConfiguration)
method wasn't called beforeIllegalArgumentException
- if passed imageAware is nullpublic void displayImage(String uri, ImageAware imageAware, DisplayImageOptions options, ImageLoadingListener listener)
init(ImageLoaderConfiguration)
method must be called before this method calluri
- Image URI (i.e. "http://site.com/image.png", "file:///mnt/sdcard/image.png")imageAware
- Image aware view
which should display imageoptions
- Options for image
decoding and displaying. If null - default display image options
from configuration will be used.listener
- Listener for image loading process. Listener fires events on
UI thread if this method is called on UI thread.IllegalStateException
- if init(ImageLoaderConfiguration)
method wasn't called beforeIllegalArgumentException
- if passed imageAware is nullpublic void displayImage(String uri, ImageAware imageAware, DisplayImageOptions options, ImageLoadingListener listener, ImageLoadingProgressListener progressListener)
init(ImageLoaderConfiguration)
method must be called before this method calluri
- Image URI (i.e. "http://site.com/image.png", "file:///mnt/sdcard/image.png")imageAware
- Image aware view
which should display imageoptions
- Options for image
decoding and displaying. If null - default display image options
from configuration will be used.listener
- Listener for image loading process. Listener fires
events on UI thread if this method is called on UI thread.progressListener
- Listener for image loading progress. Listener fires events on UI thread if this method
is called on UI thread. Caching on disk should be enabled in
options to make
this listener work.IllegalStateException
- if init(ImageLoaderConfiguration)
method wasn't called beforeIllegalArgumentException
- if passed imageAware is nullpublic void displayImage(String uri, ImageAware imageAware, DisplayImageOptions options, ImageSize targetSize, ImageLoadingListener listener, ImageLoadingProgressListener progressListener)
init(ImageLoaderConfiguration)
method must be called before this method calluri
- Image URI (i.e. "http://site.com/image.png", "file:///mnt/sdcard/image.png")imageAware
- Image aware view
which should display imageoptions
- Options for image
decoding and displaying. If null - default display image options
from configuration will be used.targetSize
- ImageSize Image target size. If null - size will depend on the viewlistener
- Listener for image loading process. Listener fires
events on UI thread if this method is called on UI thread.progressListener
- Listener for image loading progress. Listener fires events on UI thread if this method
is called on UI thread. Caching on disk should be enabled in
options to make
this listener work.IllegalStateException
- if init(ImageLoaderConfiguration)
method wasn't called beforeIllegalArgumentException
- if passed imageAware is nullpublic void displayImage(String uri, android.widget.ImageView imageView)
init(ImageLoaderConfiguration)
method must be called before this method calluri
- Image URI (i.e. "http://site.com/image.png", "file:///mnt/sdcard/image.png")imageView
- ImageView
which should display imageIllegalStateException
- if init(ImageLoaderConfiguration)
method wasn't called beforeIllegalArgumentException
- if passed imageView is nullpublic void displayImage(String uri, android.widget.ImageView imageView, ImageSize targetImageSize)
init(ImageLoaderConfiguration)
method must be called before this method calluri
- Image URI (i.e. "http://site.com/image.png", "file:///mnt/sdcard/image.png")imageView
- ImageView
which should display imageIllegalStateException
- if init(ImageLoaderConfiguration)
method wasn't called beforeIllegalArgumentException
- if passed imageView is nullpublic void displayImage(String uri, android.widget.ImageView imageView, DisplayImageOptions options)
init(ImageLoaderConfiguration)
method must be called before this method calluri
- Image URI (i.e. "http://site.com/image.png", "file:///mnt/sdcard/image.png")imageView
- ImageView
which should display imageoptions
- Options for image
decoding and displaying. If null - default display image options
from configuration will be used.IllegalStateException
- if init(ImageLoaderConfiguration)
method wasn't called beforeIllegalArgumentException
- if passed imageView is nullpublic void displayImage(String uri, android.widget.ImageView imageView, ImageLoadingListener listener)
init(ImageLoaderConfiguration)
method must be called before this method calluri
- Image URI (i.e. "http://site.com/image.png", "file:///mnt/sdcard/image.png")imageView
- ImageView
which should display imagelistener
- Listener for image loading process. Listener fires events on
UI thread if this method is called on UI thread.IllegalStateException
- if init(ImageLoaderConfiguration)
method wasn't called beforeIllegalArgumentException
- if passed imageView is nullpublic void displayImage(String uri, android.widget.ImageView imageView, DisplayImageOptions options, ImageLoadingListener listener)
init(ImageLoaderConfiguration)
method must be called before this method calluri
- Image URI (i.e. "http://site.com/image.png", "file:///mnt/sdcard/image.png")imageView
- ImageView
which should display imageoptions
- Options for image
decoding and displaying. If null - default display image options
from configuration will be used.listener
- Listener for image loading process. Listener fires events on
UI thread if this method is called on UI thread.IllegalStateException
- if init(ImageLoaderConfiguration)
method wasn't called beforeIllegalArgumentException
- if passed imageView is nullpublic void displayImage(String uri, android.widget.ImageView imageView, DisplayImageOptions options, ImageLoadingListener listener, ImageLoadingProgressListener progressListener)
init(ImageLoaderConfiguration)
method must be called before this method calluri
- Image URI (i.e. "http://site.com/image.png", "file:///mnt/sdcard/image.png")imageView
- ImageView
which should display imageoptions
- Options for image
decoding and displaying. If null - default display image options
from configuration will be used.listener
- Listener for image loading process. Listener fires
events on UI thread if this method is called on UI thread.progressListener
- Listener for image loading progress. Listener fires events on UI thread if this method
is called on UI thread. Caching on disk should be enabled in
options to make
this listener work.IllegalStateException
- if init(ImageLoaderConfiguration)
method wasn't called beforeIllegalArgumentException
- if passed imageView is nullpublic void loadImage(String uri, ImageLoadingListener listener)
ImageLoadingListener.onLoadingComplete(String, View, Bitmap)
callback}.
init(ImageLoaderConfiguration)
method must be called before this method calluri
- Image URI (i.e. "http://site.com/image.png", "file:///mnt/sdcard/image.png")listener
- Listener for image loading process. Listener fires events on UI
thread if this method is called on UI thread.IllegalStateException
- if init(ImageLoaderConfiguration)
method wasn't called beforepublic void loadImage(String uri, ImageSize targetImageSize, ImageLoadingListener listener)
ImageLoadingListener.onLoadingComplete(String, View, Bitmap)
callback}.
init(ImageLoaderConfiguration)
method must be called before this method calluri
- Image URI (i.e. "http://site.com/image.png", "file:///mnt/sdcard/image.png")targetImageSize
- Minimal size for Bitmap
which will be returned in
ImageLoadingListener.onLoadingComplete(String, View,
Bitmap) callback}. Downloaded image will be decoded
and scaled to Bitmap
of the size which is equal or larger (usually a bit
larger) than incoming targetImageSize.listener
- Listener for image loading process. Listener fires
events on UI thread if this method is called on UI thread.IllegalStateException
- if init(ImageLoaderConfiguration)
method wasn't called beforepublic void loadImage(String uri, DisplayImageOptions options, ImageLoadingListener listener)
ImageLoadingListener.onLoadingComplete(String, View, Bitmap)
callback}.
init(ImageLoaderConfiguration)
method must be called before this method calluri
- Image URI (i.e. "http://site.com/image.png", "file:///mnt/sdcard/image.png")options
- Options for image
decoding and displaying. If null - default display image options
from
configuration will be used.listener
- Listener for image loading process. Listener fires events on UI
thread if this method is called on UI thread.IllegalStateException
- if init(ImageLoaderConfiguration)
method wasn't called beforepublic void loadImage(String uri, ImageSize targetImageSize, DisplayImageOptions options, ImageLoadingListener listener)
ImageLoadingListener.onLoadingComplete(String, View, Bitmap)
callback}.
init(ImageLoaderConfiguration)
method must be called before this method calluri
- Image URI (i.e. "http://site.com/image.png", "file:///mnt/sdcard/image.png")targetImageSize
- Minimal size for Bitmap
which will be returned in
ImageLoadingListener.onLoadingComplete(String, View,
Bitmap) callback}. Downloaded image will be decoded
and scaled to Bitmap
of the size which is equal or larger (usually a bit
larger) than incoming targetImageSize.options
- Options for image
decoding and displaying. If null - default display image options
from configuration will be used.listener
- Listener for image loading process. Listener fires
events on UI thread if this method is called on UI thread.IllegalStateException
- if init(ImageLoaderConfiguration)
method wasn't called beforepublic void loadImage(String uri, ImageSize targetImageSize, DisplayImageOptions options, ImageLoadingListener listener, ImageLoadingProgressListener progressListener)
ImageLoadingListener.onLoadingComplete(String, View, Bitmap)
callback}.
init(ImageLoaderConfiguration)
method must be called before this method calluri
- Image URI (i.e. "http://site.com/image.png", "file:///mnt/sdcard/image.png")targetImageSize
- Minimal size for Bitmap
which will be returned in
ImageLoadingListener.onLoadingComplete(String, View,
Bitmap) callback}. Downloaded image will be decoded
and scaled to Bitmap
of the size which is equal or larger (usually a bit
larger) than incoming targetImageSize.options
- Options for image
decoding and displaying. If null - default display image options
from configuration will be used.listener
- Listener for image loading process. Listener fires
events on UI thread if this method is called on UI thread.progressListener
- Listener for image loading progress. Listener fires events on UI thread if this method
is called on UI thread. Caching on disk should be enabled in
options to make
this listener work.IllegalStateException
- if init(ImageLoaderConfiguration)
method wasn't called beforepublic android.graphics.Bitmap loadImageSync(String uri)
init(ImageLoaderConfiguration)
method must be called before this method calluri
- Image URI (i.e. "http://site.com/image.png", "file:///mnt/sdcard/image.png")IllegalStateException
- if init(ImageLoaderConfiguration)
method wasn't called beforepublic android.graphics.Bitmap loadImageSync(String uri, DisplayImageOptions options)
init(ImageLoaderConfiguration)
method must be called before this method calluri
- Image URI (i.e. "http://site.com/image.png", "file:///mnt/sdcard/image.png")options
- Options for image
decoding and scaling. If null - default display image options
from
configuration will be used.IllegalStateException
- if init(ImageLoaderConfiguration)
method wasn't called beforepublic android.graphics.Bitmap loadImageSync(String uri, ImageSize targetImageSize)
init(ImageLoaderConfiguration)
method must be called before this method calluri
- Image URI (i.e. "http://site.com/image.png", "file:///mnt/sdcard/image.png")targetImageSize
- Minimal size for Bitmap
which will be returned. Downloaded image will be decoded
and scaled to Bitmap
of the size which is equal or larger (usually a bit
larger) than incoming targetImageSize.IllegalStateException
- if init(ImageLoaderConfiguration)
method wasn't called beforepublic android.graphics.Bitmap loadImageSync(String uri, ImageSize targetImageSize, DisplayImageOptions options)
init(ImageLoaderConfiguration)
method must be called before this method calluri
- Image URI (i.e. "http://site.com/image.png", "file:///mnt/sdcard/image.png")targetImageSize
- Minimal size for Bitmap
which will be returned. Downloaded image will be decoded
and scaled to Bitmap
of the size which is equal or larger (usually a bit
larger) than incoming targetImageSize.options
- Options for image
decoding and scaling. If null - default display image options
from configuration will be used.IllegalStateException
- if init(ImageLoaderConfiguration)
method wasn't called beforepublic void setDefaultLoadingListener(ImageLoadingListener listener)
public MemoryCache getMemoryCache()
IllegalStateException
- if init(ImageLoaderConfiguration)
method wasn't called beforepublic void clearMemoryCache()
IllegalStateException
- if init(ImageLoaderConfiguration)
method wasn't called before@Deprecated public DiskCache getDiscCache()
getDiskCache()
insteadIllegalStateException
- if init(ImageLoaderConfiguration)
method wasn't called beforepublic DiskCache getDiskCache()
IllegalStateException
- if init(ImageLoaderConfiguration)
method wasn't called before@Deprecated public void clearDiscCache()
clearDiskCache()
insteadIllegalStateException
- if init(ImageLoaderConfiguration)
method wasn't called beforepublic void clearDiskCache()
IllegalStateException
- if init(ImageLoaderConfiguration)
method wasn't called beforepublic String getLoadingUriForView(ImageAware imageAware)
ImageAware
public String getLoadingUriForView(android.widget.ImageView imageView)
ImageView
public void cancelDisplayTask(ImageAware imageAware)
ImageAware
.imageAware
- ImageAware
for
which display task will be cancelledpublic void cancelDisplayTask(android.widget.ImageView imageView)
ImageView
.imageView
- ImageView
for which display task will be cancelledpublic void denyNetworkDownloads(boolean denyNetworkDownloads)
ImageLoadingListener.onLoadingFailed(String, View, FailReason)
callback will be fired with
FailReason.FailType#NETWORK_DENIED
denyNetworkDownloads
- pass true - to deny engine to download images from the network; false -
to allow engine to download images from network.public void handleSlowNetwork(boolean handleSlowNetwork)
FlushedInputStream
for network downloads to handle this known problem or not.handleSlowNetwork
- pass true - to use FlushedInputStream
for network downloads; false
- otherwise.public void pause()
resumed
.
public void resume()
public void stop()
public void destroy()