com.nostra13.universalimageloader.core
Class ImageLoader

java.lang.Object
  extended by com.nostra13.universalimageloader.core.ImageLoader

public class ImageLoader
extends java.lang.Object

Singletone for image loading and displaying at ImageViews
NOTE: init(ImageLoaderConfiguration) method must be called before any other method.

Author:
Sergey Tarasevich (nostra13[at]gmail[dot]com)

Field Summary
static java.lang.String TAG
           
 
Constructor Summary
protected ImageLoader()
           
 
Method Summary
 void cancelDisplayTask(android.widget.ImageView imageView)
          Cancel the task of loading and displaying image for passed ImageView.
 void clearDiscCache()
          Clear disc cache.
 void clearMemoryCache()
          Clear memory cache.
 void displayImage(java.lang.String uri, android.widget.ImageView imageView)
          Adds display image task to execution pool.
 void displayImage(java.lang.String uri, android.widget.ImageView imageView, DisplayImageOptions options)
          Adds display image task to execution pool.
 void displayImage(java.lang.String uri, android.widget.ImageView imageView, DisplayImageOptions options, ImageLoadingListener listener)
          Adds display image task to execution pool.
 void displayImage(java.lang.String uri, android.widget.ImageView imageView, ImageLoadingListener listener)
          Adds display image task to execution pool.
 DiscCacheAware getDiscCache()
          Returns disc cache
static ImageLoader getInstance()
          Returns singleton class instance
 java.lang.String getLoadingUriForView(android.widget.ImageView imageView)
          Returns URI of image which is loading at this moment into passed ImageView
 MemoryCacheAware<java.lang.String,android.graphics.Bitmap> getMemoryCache()
          Returns memory cache
 void init(ImageLoaderConfiguration configuration)
          Initializes ImageLoader's singleton instance with configuration.
 void loadImage(android.content.Context context, java.lang.String uri, DisplayImageOptions options, ImageLoadingListener listener)
          Adds load image task to execution pool.
 void loadImage(android.content.Context context, java.lang.String uri, ImageLoadingListener listener)
          Adds load image task to execution pool.
 void loadImage(android.content.Context context, java.lang.String uri, ImageSize minImageSize, DisplayImageOptions options, ImageLoadingListener listener)
          Adds load image task to execution pool.
 void loadImage(android.content.Context context, java.lang.String uri, ImageSize minImageSize, ImageLoadingListener listener)
          Adds load image task to execution pool.
 void pause()
          Pause ImageLoader.
 void resume()
          Resumes waiting "load&display" tasks
 void stop()
          Stops all running display image tasks, discards all other scheduled tasks
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

TAG

public static final java.lang.String TAG
Constructor Detail

ImageLoader

protected ImageLoader()
Method Detail

getInstance

public static ImageLoader getInstance()
Returns singleton class instance


init

public void init(ImageLoaderConfiguration configuration)
Initializes ImageLoader's singleton instance with configuration. Method should be called once (each following call will have no effect)

Parameters:
configuration - ImageLoader configuration
Throws:
java.lang.IllegalArgumentException - if configuration parameter is null

displayImage

public void displayImage(java.lang.String uri,
                         android.widget.ImageView imageView)
Adds display image task to execution pool. Image will be set to ImageView when it's turn.
Default display image options from configuration will be used.
NOTE: init(ImageLoaderConfiguration) method must be called before this method call

Parameters:
uri - Image URI (i.e. "http://site.com/image.png", "file:///mnt/sdcard/image.png")
imageView - ImageView which should display image
Throws:
java.lang.RuntimeException - if init(ImageLoaderConfiguration) method wasn't called before

displayImage

public void displayImage(java.lang.String uri,
                         android.widget.ImageView imageView,
                         DisplayImageOptions options)
Adds display image task to execution pool. Image will be set to ImageView when it's turn.
NOTE: init(ImageLoaderConfiguration) method must be called before this method call

Parameters:
uri - Image URI (i.e. "http://site.com/image.png", "file:///mnt/sdcard/image.png")
imageView - ImageView which should display image
options - Display image options for image displaying. If null - default display image options from configuration will be used.
Throws:
java.lang.RuntimeException - if init(ImageLoaderConfiguration) method wasn't called before

displayImage

public void displayImage(java.lang.String uri,
                         android.widget.ImageView imageView,
                         ImageLoadingListener listener)
Adds display image task to execution pool. Image will be set to ImageView when it's turn.
Default display image options from configuration will be used.
NOTE: init(ImageLoaderConfiguration) method must be called before this method call

Parameters:
uri - Image URI (i.e. "http://site.com/image.png", "file:///mnt/sdcard/image.png")
imageView - ImageView which should display image
listener - Listener for image loading process. Listener fires events on UI thread.
Throws:
java.lang.RuntimeException - if init(ImageLoaderConfiguration) method wasn't called before

displayImage

public void displayImage(java.lang.String uri,
                         android.widget.ImageView imageView,
                         DisplayImageOptions options,
                         ImageLoadingListener listener)
Adds display image task to execution pool. Image will be set to ImageView when it's turn.
NOTE: init(ImageLoaderConfiguration) method must be called before this method call

Parameters:
uri - Image URI (i.e. "http://site.com/image.png", "file:///mnt/sdcard/image.png")
imageView - ImageView which should display image
options - Display image options for image displaying. If null - default display image options from configuration will be used.
listener - Listener for image loading process. Listener fires events on UI thread.
Throws:
java.lang.RuntimeException - if init(ImageLoaderConfiguration) method wasn't called before

loadImage

public void loadImage(android.content.Context context,
                      java.lang.String uri,
                      ImageLoadingListener listener)
Adds load image task to execution pool. Image will be returned with callback.
NOTE: init(ImageLoaderConfiguration) method must be called before this method call

Parameters:
context - Application context (used for creation of fake ImageView)
uri - 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.

loadImage

public void loadImage(android.content.Context context,
                      java.lang.String uri,
                      ImageSize minImageSize,
                      ImageLoadingListener listener)
Adds load image task to execution pool. Image will be returned with callback.
NOTE: init(ImageLoaderConfiguration) method must be called before this method call

Parameters:
context - Application context (used for creation of fake ImageView)
uri - Image URI (i.e. "http://site.com/image.png", "file:///mnt/sdcard/image.png")
minImageSize - Minimal size for Bitmap which will be returned in callback. Downloaded image will be decoded and scaled to Bitmap of the size which is equal or larger (usually a bit larger) than incoming minImageSize .
listener - Listener for image loading process. Listener fires events on UI thread.

loadImage

public void loadImage(android.content.Context context,
                      java.lang.String uri,
                      DisplayImageOptions options,
                      ImageLoadingListener listener)
Adds load image task to execution pool. Image will be returned with callback.
NOTE: init(ImageLoaderConfiguration) method must be called before this method call

Parameters:
context - Application context (used for creation of fake ImageView)
uri - Image URI (i.e. "http://site.com/image.png", "file:///mnt/sdcard/image.png")
options - Display image options for image displaying. If null - default display image options from configuration will be used.
Incoming options should contain FakeBitmapDisplayer as displayer.
listener - Listener for image loading process. Listener fires events on UI thread.

loadImage

public void loadImage(android.content.Context context,
                      java.lang.String uri,
                      ImageSize minImageSize,
                      DisplayImageOptions options,
                      ImageLoadingListener listener)
Adds load image task to execution pool. Image will be returned with callback.
NOTE: init(ImageLoaderConfiguration) method must be called before this method call

Parameters:
context - Application context (used for creation of fake ImageView)
uri - Image URI (i.e. "http://site.com/image.png", "file:///mnt/sdcard/image.png")
minImageSize - Minimal size for Bitmap which will be returned in callback. Downloaded image will be decoded and scaled to Bitmap of the size which is equal or larger (usually a bit larger) than incoming minImageSize .
options - Display image options for image displaying. If null - default display image options from configuration will be used.
Incoming options should contain FakeBitmapDisplayer as displayer.
listener - Listener for image loading process. Listener fires events on UI thread.

getMemoryCache

public MemoryCacheAware<java.lang.String,android.graphics.Bitmap> getMemoryCache()
Returns memory cache


clearMemoryCache

public void clearMemoryCache()
Clear memory cache.
Do nothing if init(ImageLoaderConfiguration) method wasn't called before.


getDiscCache

public DiscCacheAware getDiscCache()
Returns disc cache


clearDiscCache

public void clearDiscCache()
Clear disc cache.
Do nothing if init(ImageLoaderConfiguration) method wasn't called before.


getLoadingUriForView

public java.lang.String getLoadingUriForView(android.widget.ImageView imageView)
Returns URI of image which is loading at this moment into passed ImageView


cancelDisplayTask

public void cancelDisplayTask(android.widget.ImageView imageView)
Cancel the task of loading and displaying image for passed ImageView.

Parameters:
imageView - ImageView for which display task will be cancelled

pause

public void pause()
Pause ImageLoader. All new "load&display" tasks won't be executed until ImageLoader is resumed.
Already running tasks are not paused.


resume

public void resume()
Resumes waiting "load&display" tasks


stop

public void stop()
Stops all running display image tasks, discards all other scheduled tasks



Copyright © 2011-2013. All Rights Reserved.