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 QueueProcessingType DEFAULT_TASK_PROCESSING_TYPE
          
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(DiskCache diskCache)
          Deprecated. Use diskCache(com.nostra13.universalimageloader.cache.disc.DiskCache)
 ImageLoaderConfiguration.Builder discCacheExtraOptions(int maxImageWidthForDiskCache, int maxImageHeightForDiskCache, BitmapProcessor processorForDiskCache)
          Deprecated. Use diskCacheExtraOptions(int, int, com.nostra13.universalimageloader.core.process.BitmapProcessor) instead
 ImageLoaderConfiguration.Builder discCacheFileCount(int maxFileCount)
          Deprecated. Use diskCacheFileCount(int) instead
 ImageLoaderConfiguration.Builder discCacheFileNameGenerator(FileNameGenerator fileNameGenerator)
          Deprecated. Use diskCacheFileNameGenerator(com.nostra13.universalimageloader.cache.disc.naming.FileNameGenerator)
 ImageLoaderConfiguration.Builder discCacheSize(int maxCacheSize)
          Deprecated. Use diskCacheSize(int) instead
 ImageLoaderConfiguration.Builder diskCache(DiskCache diskCache)
          Sets disk cache for images.
 ImageLoaderConfiguration.Builder diskCacheExtraOptions(int maxImageWidthForDiskCache, int maxImageHeightForDiskCache, BitmapProcessor processorForDiskCache)
          Sets options for resizing/compressing of downloaded images before saving to disk cache.
 ImageLoaderConfiguration.Builder diskCacheFileCount(int maxFileCount)
          Sets maximum file count in disk cache directory.
 ImageLoaderConfiguration.Builder diskCacheFileNameGenerator(FileNameGenerator fileNameGenerator)
          Sets name generator for files cached in disk cache.
 ImageLoaderConfiguration.Builder diskCacheSize(int maxCacheSize)
          Sets maximum disk cache size for images (in bytes).
 ImageLoaderConfiguration.Builder imageDecoder(ImageDecoder imageDecoder)
          Sets utility which will be responsible for decoding of image stream.
 ImageLoaderConfiguration.Builder imageDownloader(ImageDownloader imageDownloader)
          Sets utility which will be responsible for downloading of image.
 ImageLoaderConfiguration.Builder memoryCache(MemoryCache 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 memoryCacheSizePercentage(int availableMemoryPercent)
          Sets maximum memory cache size (in percent of available app memory) for bitmaps.
 ImageLoaderConfiguration.Builder taskExecutor(Executor executor)
          Sets custom executor for tasks of loading and displaying images.
 ImageLoaderConfiguration.Builder taskExecutorForCachedImages(Executor executorForCachedImages)
          Sets custom executor for tasks of displaying cached on disk images (these tasks are executed quickly so UIL prefer to use separate executor for them).
 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.
 ImageLoaderConfiguration.Builder writeDebugLogs()
          Enables detail logging of ImageLoader work.
 
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_TASK_PROCESSING_TYPE

public static final QueueProcessingType DEFAULT_TASK_PROCESSING_TYPE

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

@Deprecated
public ImageLoaderConfiguration.Builder discCacheExtraOptions(int maxImageWidthForDiskCache,
                                                                         int maxImageHeightForDiskCache,
                                                                         BitmapProcessor processorForDiskCache)
Deprecated. Use diskCacheExtraOptions(int, int, com.nostra13.universalimageloader.core.process.BitmapProcessor) instead


diskCacheExtraOptions

public ImageLoaderConfiguration.Builder diskCacheExtraOptions(int maxImageWidthForDiskCache,
                                                              int maxImageHeightForDiskCache,
                                                              BitmapProcessor processorForDiskCache)
Sets options for resizing/compressing of downloaded images before saving to disk cache.
NOTE: Use this option only when you have appropriate needs. It can make ImageLoader slower.

Parameters:
maxImageWidthForDiskCache - Maximum width of downloaded images for saving at disk cache
maxImageHeightForDiskCache - Maximum height of downloaded images for saving at disk cache
processorForDiskCache - null-ok; Bitmap processor which process images before saving them in disc cache

taskExecutor

public ImageLoaderConfiguration.Builder taskExecutor(Executor executor)
Sets custom executor for tasks of loading and displaying images.

NOTE: If you set custom executor then following configuration options will not be considered for this executor:

See Also:
taskExecutorForCachedImages(Executor)

taskExecutorForCachedImages

public ImageLoaderConfiguration.Builder taskExecutorForCachedImages(Executor executorForCachedImages)
Sets custom executor for tasks of displaying cached on disk images (these tasks are executed quickly so UIL prefer to use separate executor for them).

If you set the same executor for general tasks and tasks about cached images (this method) then these tasks will be in the same thread pool. So short-lived tasks can wait a long time for their turn.

NOTE: If you set custom executor then following configuration options will not be considered for this executor:

See Also:
taskExecutor(Executor)

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. Should 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.


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 - 1/8 of available app memory.
NOTE: If you use this method then LruMemoryCache will be used as memory cache. You can use memoryCache(MemoryCache) method to set your own implementation of MemoryCache.


memoryCacheSizePercentage

public ImageLoaderConfiguration.Builder memoryCacheSizePercentage(int availableMemoryPercent)
Sets maximum memory cache size (in percent of available app memory) for bitmaps.
Default value - 1/8 of available app memory.
NOTE: If you use this method then LruMemoryCache will be used as memory cache. You can use memoryCache(MemoryCache) method to set your own implementation of MemoryCache.


memoryCache

public ImageLoaderConfiguration.Builder memoryCache(MemoryCache memoryCache)
Sets memory cache for bitmaps.
Default value - LruMemoryCache with limited memory cache size (size = 1/8 of available app memory)

NOTE: If you set custom memory cache then following configuration option will not be considered:


discCacheSize

@Deprecated
public ImageLoaderConfiguration.Builder discCacheSize(int maxCacheSize)
Deprecated. Use diskCacheSize(int) instead


diskCacheSize

public ImageLoaderConfiguration.Builder diskCacheSize(int maxCacheSize)
Sets maximum disk cache size for images (in bytes).
By default: disk cache is unlimited.
NOTE: If you use this method then LruDiscCache will be used as disk cache. You can use diskCache(DiskCache) method for introduction your own implementation of DiskCache


discCacheFileCount

@Deprecated
public ImageLoaderConfiguration.Builder discCacheFileCount(int maxFileCount)
Deprecated. Use diskCacheFileCount(int) instead


diskCacheFileCount

public ImageLoaderConfiguration.Builder diskCacheFileCount(int maxFileCount)
Sets maximum file count in disk cache directory.
By default: disk cache is unlimited.
NOTE: If you use this method then LruDiscCache will be used as disk cache. You can use diskCache(DiskCache) method for introduction your own implementation of DiskCache


discCacheFileNameGenerator

@Deprecated
public ImageLoaderConfiguration.Builder discCacheFileNameGenerator(FileNameGenerator fileNameGenerator)
Deprecated. Use diskCacheFileNameGenerator(com.nostra13.universalimageloader.cache.disc.naming.FileNameGenerator)


diskCacheFileNameGenerator

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


discCache

@Deprecated
public ImageLoaderConfiguration.Builder discCache(DiskCache diskCache)
Deprecated. Use diskCache(com.nostra13.universalimageloader.cache.disc.DiskCache)


diskCache

public ImageLoaderConfiguration.Builder diskCache(DiskCache diskCache)
Sets disk cache for images.
Default value - BaseDiscCache. Cache directory is defined by StorageUtils.getCacheDirectory(Context).

NOTE: If you set custom disk cache then following configuration option will not be considered:


imageDownloader

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


imageDecoder

public ImageLoaderConfiguration.Builder imageDecoder(ImageDecoder imageDecoder)
Sets utility which will be responsible for decoding of image stream.
Default value - DefaultConfigurationFactory.createImageDecoder()


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


writeDebugLogs

public ImageLoaderConfiguration.Builder writeDebugLogs()
Enables detail logging of ImageLoader work. To prevent detail logs don't call this method. Consider L.disableLogging() to disable ImageLoader logging completely (even error logs)


build

public ImageLoaderConfiguration build()
Builds configured ImageLoaderConfiguration object



Copyright © 2011-2014. All Rights Reserved.