Edit NEW:
/**
For loading optimizations such as ListView:
Monitors the slide state to set whether the picture is currently loaded.
Slide the state without loading, allowing the ListView to slide more smoothly.
Writing:
New Pauseonscrolllistener (Imageloader.getinstance (), False, True, this);
This is a slide monitor in a universal-image-loader, which assigns it to the listview of the sliding Monitor.
For example: Listview.setonscrolllistener (New Pauseonscrolllistener (Imageloader.getinstance (), False, True, this));
Four parameters in listening, 1: Object, 2: Whether to stop loading the picture when sliding slowly, 3: Whether to stop loading the picture when sliding quickly; 4: Context.
The main parameter is the 2,3 setting. Recommendation 2 sets false,3 to true, meaning that the image is loaded slowly while sliding, but does not load when fast, allowing the ListView to slide happily.
*/
Currently the most widely used Android, the effect is also very good image processing loader.
The usage is needless to say, Baidu a lot of.
The specific configuration is described in detail to preserve future use.
/**
* Introduction to Configuration of all configurations
*/
Memory Cache settings Options (maximum picture width, maximum picture height) default current screen resolution
. Memorycacheextraoptions (480, 800)
Hard disk cache settings options (maximum picture width, maximum picture height, compression format, compression quality, processor)
. disccacheextraoptions (480, +, Compressformat.jpeg, (+), NULL)
Set up a thread pool for customizing load and display pictures
. Taskexecutor (Defaultconfigurationfactory.createexecutor (3,thread.norm_priority
-1, Queueprocessingtype.fifo))
Set up a thread pool for custom load and display memory caches or hard disk cache images
. Taskexecutorforcachedimages (Defaultconfigurationfactory.createexecutor (3,thread.norm_priority
-1, Queueprocessingtype.fifo))
Set the display picture thread pool size, default to 3
Note: If Taskexecutor or taskexecutorforcachedimages is set, this setting is not valid
. ThreadPoolSize (3)
Sets the priority of the picture load thread, which defaults to Thread.norm_priority-1
Note: If Taskexecutor or taskexecutorforcachedimages is set, this setting is not valid
. ThreadPriority (Thread.norm_priority-1)
Sets the type of picture loading and display queue processing by default to Queueprocessingtype.fifo
Note: If Taskexecutor or taskexecutorforcachedimages is set, this setting is not valid
. Tasksprocessingorder (Queueprocessingtype.fifo)
Set deny cache in memory one picture multiple size defaults to allow, (same picture URL) save different size picture according to ImageView of different size
. Denycacheimagemultiplesizesinmemory ()
Set the memory cache to default to a 1/8-size Lrumemorycache of available memory currently applied
. MemoryCache (New Lrumemorycache (2 * 1024 * 1024))
Setting the maximum size of the memory cache defaults to 1/8 of the available memory for the current application
. memorycachesize (2 * 1024 * 1024)
Set the maximum memory cache size as a percentage of the current app's available memory default to 1/8 of the available memory currently applied
. Memorycachesizepercentage (13)
Setting the hard disk cache
Default is Storageutils.getcachedirectory (Getapplicationcontext ())
That is,/mnt/sdcard/android/data/package name/cache/
. Disccache (New
Unlimiteddisccache (Storageutils.getcachedirectory (Getapplicationcontext ())))
Set the maximum size of the hard disk cache
. disccachesize (50 * 1024 * 1024)
To set the maximum number of files for a hard disk cache
. Disccachefilecount (100)
Set the hard disk cache file name generation specification
Default to New Hashcodefilenamegenerator ()
. Disccachefilenamegenerator (New Md5filenamegenerator ())
Set up Picture downloader
Default is Defaultconfigurationfactory.createbitmapdisplayer ()
. Imagedownloader (
New Httpclientimagedownloader (Getapplicationcontext (),
New Defaulthttpclient ()))
Set up a picture decoder
Default is Defaultconfigurationfactory.createimagedecoder (false)
. Imagedecoder (Defaultconfigurationfactory.createimagedecoder (false))
Set the default picture display options
Default is Displayimageoptions.createsimple ()
. Defaultdisplayimageoptions (Displayimageoptions.createsimple ())
Print Debuglogs
. Writedebuglogs ()
Establish
. build ();
/**
* Displayimageoptions All configuration Introduction
*/
Set the default picture when the picture is loaded
. showimageonloading (R.drawable.ic_chat_def_pic)
Set the default picture for picture loading failure
. Showimageonfail (R.drawable.ic_chat_def_pic_failure)
Sets the default picture when the picture URI is empty
. Showimageforemptyuri (R.drawable.ic_chat_def_pic)
Sets whether the view is reset before loading
. Resetviewbeforeloading (False)
Set delay part time to start loading
Default is 0
. delaybeforeloading (100)
Setting Add to Memory cache
Default is False
. Cacheinmemory (True)
Settings added to the hard disk cache
Default is False
. Cacheondisc (True)
Set the decoded image of a scale type
Default is Imagescaletype.in_sample_power_of_2
. Imagescaletype (Imagescaletype.in_sample_power_of_2)
Set Bitmap Image decoding configuration
Default is Bitmap.Config.ARGB_8888
. Bitmapconfig (Bitmap.Config.ARGB_8888)
Setting image decoding for options
. Decodingoptions (New Options ())
Setting up a custom display
Default is Defaultconfigurationfactory.createbitmapdisplayer ()
. Displayer (New Fadeinbitmapdisplayer (300))
Set up a custom handler
Default to New Handler ()
. Handler (new handler ())
Establish
. build ();
Copyright NOTICE: This article for Bo Master original article, without Bo Master permission not reproduced.
Universal-image-loader Picture Asynchronous loading