com.nostra13.universalimageloader.core
Class ImageLoaderConfiguration.Builder

java.lang.Object
  extended by com.nostra13.universalimageloader.core.ImageLoaderConfiguration.Builder
Enclosing class:
ImageLoaderConfiguration

public static class ImageLoaderConfiguration.Builder
extends Object

Builder for ImageLoaderConfiguration

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

Field Summary
static int DEFAULT_MEMORY_CACHE_SIZE
          2097152
static int DEFAULT_THREAD_POOL_SIZE
          3
static int DEFAULT_THREAD_PRIORITY
          4
 
Constructor Summary
ImageLoaderConfiguration.Builder(android.content.Context context)
           
 
Method Summary
 ImageLoaderConfiguration build()
          Builds configured ImageLoaderConfiguration object
 ImageLoaderConfiguration.Builder defaultDisplayImageOptions(DisplayImageOptions defaultDisplayImageOptions)
          Sets default display image options for image displaying.
 ImageLoaderConfiguration.Builder denyCacheImageMultipleSizesInMemory()
          When you display an image in a small ImageView and later you try to display this image (from identical URI) in a larger ImageView so decoded image of bigger size will be cached in memory as a previous decoded image of smaller size.
 ImageLoaderConfiguration.Builder discCache(DiscCacheAware discCache)
          Sets disc cache for images.
 ImageLoaderConfiguration.Builder discCacheExtraOptions(int maxImageWidthForDiscCache, int maxImageHeightForDiscCache, android.graphics.Bitmap.CompressFormat compressFormat, int compressQuality)
          Sets options for resizing/compressing of downloaded images before saving to disc cache.
 ImageLoaderConfiguration.Builder discCacheFileCount(int maxFileCount)
          Sets maximum file count in disc cache directory.
 ImageLoaderConfiguration.Builder discCacheFileNameGenerator(FileNameGenerator fileNameGenerator)
          Sets name generator for files cached in disc cache.
 ImageLoaderConfiguration.Builder discCacheSize(int maxCacheSize)
          Sets maximum disc cache size for images (in bytes).
 ImageLoaderConfiguration.Builder enableLogging()
          Enabled detail logging of ImageLoader work
 ImageLoaderConfiguration.Builder imageDownloader(ImageDownloader imageDownloader)
          Sets utility which will be responsible for downloading of image.
 ImageLoaderConfiguration.Builder memoryCache(MemoryCacheAware<String,android.graphics.Bitmap> memoryCache)
          Sets memory cache for bitmaps.
 ImageLoaderConfiguration.Builder memoryCacheExtraOptions(int maxImageWidthForMemoryCache, int maxImageHeightForMemoryCache)
          Sets options for memory cache
 ImageLoaderConfiguration.Builder memoryCacheSize(int memoryCacheSize)
          Sets maximum memory cache size for bitmaps (in bytes).
 ImageLoaderConfiguration.Builder offOutOfMemoryHandling()
          ImageLoader try clean memory and re-display image it self when OutOfMemoryError occurs.
 ImageLoaderConfiguration.Builder tasksProcessingOrder(QueueProcessingType tasksProcessingType)
          Sets type of queue processing for tasks for loading and displaying images.
 ImageLoaderConfiguration.Builder threadPoolSize(int threadPoolSize)
          Sets thread pool size for image display tasks.
 ImageLoaderConfiguration.Builder threadPriority(int threadPriority)
          Sets the priority for image loading threads.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

DEFAULT_THREAD_POOL_SIZE

public static final int DEFAULT_THREAD_POOL_SIZE
3

See Also:
Constant Field Values

DEFAULT_THREAD_PRIORITY

public static final int DEFAULT_THREAD_PRIORITY
4

See Also:
Constant Field Values

DEFAULT_MEMORY_CACHE_SIZE

public static final int DEFAULT_MEMORY_CACHE_SIZE
2097152

See Also:
Constant Field Values
Constructor Detail

ImageLoaderConfiguration.Builder

public ImageLoaderConfiguration.Builder(android.content.Context context)
Method Detail

memoryCacheExtraOptions

public ImageLoaderConfiguration.Builder memoryCacheExtraOptions(int maxImageWidthForMemoryCache,
                                                                int maxImageHeightForMemoryCache)
Sets options for memory cache

Parameters:
maxImageWidthForMemoryCache - Maximum image width which will be used for memory saving during decoding an image to Bitmap. Default value - device's screen width
maxImageHeightForMemoryCache - Maximum image height which will be used for memory saving during decoding an image to Bitmap. Default value - device's screen height

discCacheExtraOptions

public ImageLoaderConfiguration.Builder discCacheExtraOptions(int maxImageWidthForDiscCache,
                                                              int maxImageHeightForDiscCache,
                                                              android.graphics.Bitmap.CompressFormat compressFormat,
                                                              int compressQuality)
Sets options for resizing/compressing of downloaded images before saving to disc cache.
NOTE: Use this option only when you have appropriate needs. It can make ImageLoader slower.

Parameters:
maxImageWidthForDiscCache - Maximum width of downloaded images for saving at disc cache
maxImageHeightForDiscCache - Maximum height of downloaded images for saving at disc cache
compressFormat - Compress format downloaded images to save them at disc cache
compressQuality - Hint to the compressor, 0-100. 0 meaning compress for small size, 100 meaning compress for max quality. Some formats, like PNG which is lossless, will ignore the quality setting

threadPoolSize

public ImageLoaderConfiguration.Builder threadPoolSize(int threadPoolSize)
Sets thread pool size for image display tasks.
Default value - this


threadPriority

public ImageLoaderConfiguration.Builder threadPriority(int threadPriority)
Sets the priority for image loading threads. Must be NOT greater than Thread.MAX_PRIORITY or less than Thread.MIN_PRIORITY
Default value - this


denyCacheImageMultipleSizesInMemory

public ImageLoaderConfiguration.Builder denyCacheImageMultipleSizesInMemory()
When you display an image in a small ImageView and later you try to display this image (from identical URI) in a larger ImageView so decoded image of bigger size will be cached in memory as a previous decoded image of smaller size.
So the default behavior is to allow to cache multiple sizes of one image in memory. You can deny it by calling this method: so when some image will be cached in memory then previous cached size of this image (if it exists) will be removed from memory cache before.


offOutOfMemoryHandling

public ImageLoaderConfiguration.Builder offOutOfMemoryHandling()
ImageLoader try clean memory and re-display image it self when OutOfMemoryError occurs. You can switch off this feature by this method and process error by your way (you can know that OutOfMemoryError occurred if you got FailReason.OUT_OF_MEMORY in ImageLoadingListener#onLoadingFailed(FailReason)).


tasksProcessingOrder

public ImageLoaderConfiguration.Builder tasksProcessingOrder(QueueProcessingType tasksProcessingType)
Sets type of queue processing for tasks for loading and displaying images.
Default value - QueueProcessingType.FIFO


memoryCacheSize

public ImageLoaderConfiguration.Builder memoryCacheSize(int memoryCacheSize)
Sets maximum memory cache size for bitmaps (in bytes).
Default value - this
NOTE: If you use this method then UsingFreqLimitedCache will be used as memory cache. You can use memoryCache(MemoryCacheAware) method for introduction your own implementation of MemoryCacheAware.


memoryCache

public ImageLoaderConfiguration.Builder memoryCache(MemoryCacheAware<String,android.graphics.Bitmap> memoryCache)
Sets memory cache for bitmaps.
Default value - UsingFreqLimitedCache with limited memory cache size (size = this)
NOTE: You can use memoryCacheSize(int) method instead of this method to simplify memory cache tuning.


discCacheSize

public ImageLoaderConfiguration.Builder discCacheSize(int maxCacheSize)
Sets maximum disc cache size for images (in bytes).
By default: disc cache is unlimited.
NOTE: If you use this method then TotalSizeLimitedDiscCache will be used as disc cache. You can use discCache(DiscCacheAware) method for introduction your own implementation of DiscCacheAware


discCacheFileCount

public ImageLoaderConfiguration.Builder discCacheFileCount(int maxFileCount)
Sets maximum file count in disc cache directory.
By default: disc cache is unlimited.
NOTE: If you use this method then FileCountLimitedDiscCache will be used as disc cache. You can use discCache(DiscCacheAware) method for introduction your own implementation of DiscCacheAware


discCacheFileNameGenerator

public ImageLoaderConfiguration.Builder discCacheFileNameGenerator(FileNameGenerator fileNameGenerator)
Sets name generator for files cached in disc cache.
Default value - DefaultConfigurationFactory.createFileNameGenerator()


imageDownloader

public ImageLoaderConfiguration.Builder imageDownloader(ImageDownloader imageDownloader)
Sets utility which will be responsible for downloading of image.
Default value - DefaultConfigurationFactory.createImageDownloader()


discCache

public ImageLoaderConfiguration.Builder discCache(DiscCacheAware discCache)
Sets disc cache for images.
Default value - UnlimitedDiscCache. Cache directory is defined by StorageUtils.getCacheDirectory(Context).


defaultDisplayImageOptions

public ImageLoaderConfiguration.Builder defaultDisplayImageOptions(DisplayImageOptions defaultDisplayImageOptions)
Sets default display image options for image displaying. These options will be used for every image display call without passing custom options
Default value - Simple options


enableLogging

public ImageLoaderConfiguration.Builder enableLogging()
Enabled detail logging of ImageLoader work


build

public ImageLoaderConfiguration build()
Builds configured ImageLoaderConfiguration object



Copyright © 2011-2013. All Rights Reserved.