This is intended to directly tell you how to use it, in fact, this is not a difficult framework, the approximate use of the process is as follows:
Get cached picture directory file Cachedir = storageutils.getowncachedirectory (activity, "Imageloader/cache"); mageloaderconfiguration config = new Imageloaderconfiguration.builder (activity). Memorycacheextraoptions (800, 760)// Save the maximum length and width of each cached picture. ThreadPoolSize (3). DiskCache (New Unlimiteddisccache (Cachedir))//thread pool size This is actually the default is 3.memoryCacheSize (2 * 1024)//Set the maximum bytes of the cache. Denycacheimagemultiplesizesinmemory ()//cache Displays the same picture of different sizes. Imagedownloader (New Baseimagedownloader (Activity, 5 * 1000, 30 * 1000)) connecttimeout//s) Timeout time. build (); Imageloader.init (config);
The directory set above in my phone's/storage/sdcard0/imageloader/cache file is no. jpg or. png ending, is a bunch of unformatted files that can be exported by extension open
The second step sets the display picture options:
</pre><p></p><p><pre name= "code" class= "java" >displayimageoptionsoptions = new Displayimageoptions.builder (). showimageonloading (R.drawable.ic_launcher)//Set the picture that the picture displays during the download . Showimageforemptyuri (R.drawable.ic_launcher)//Set the picture URI to be displayed when it is empty or wrong . Showimageonfail (r.drawable.ic_ Launcher)//sets the picture to be displayed when the image is loaded/decoded in error. Cacheinmemory (TRUE)//sets the downloaded picture to be in memory . Cacheondisk (TRUE)//Set the downloaded picture is slow to exist on the SD card . Displayer (New Fadeinbitmapdisplayer). Considerexifparams (True). Displayer (New Fadeinbitmapdisplayer (100 )//The animation time when the picture is loaded and then fades in. Displayer (new Roundedbitmapdisplayer (1)). build ();//This must be set, do not set the words will cause the picture can not be covered with the entire control, this is to set the fillet effect, If you don't like rounded corners can be set to 1 almost nothing effect
Using the code above, you can use it normally.
Here is an official give a sample, will Android look at the following code should know how to use it, very simple
public class Imagelistactivity extends Abslistviewbaseactivity {displayimageoptions Options String[] imageurls; @Overridepublic void OnCreate (Bundle savedinstancestate) {super.oncreate (savedinstancestate); Setcontentview (r.layout.ac_image_list); Bundle bundle = Getintent (). Getextras (); imageurls = Bundle.getstringarray (extra.images); options = new Displayimageoptions.builder (). showimageonloading (r.drawable.ic_stub). Showimageforemptyuri (R.drawable.ic_empty) . Showimageonfail (R.drawable.ic_error). Cacheinmemory (True). Cacheondisk (True). Considerexifparams (True). Displayer (new Roundedbitmapdisplayer). Build (); listview = (ListView) Findviewbyid (Android. r.id.list);((listview). Setadapter (New Itemadapter ()); Listview.setonitemclicklistener (new Onitemclicklistener () {@Overridepublic void Onitemclick (adapterview<?> parent, view view, int position, long id) {s Tartimagepageractivity (position);}});
Note here, when the return button is pressed to clear the memory of the picture, we have to rely too much on automatic memory management, and sometimes manually to remove the memory is better, @Overridepublic void onbackpressed () { AnimateFirstDisplayListener.displayedImages.clear (); super.onbackpressed ();} private void startimagepageractivity (int position) {Intent Intent = new Intent (this, imagepageractivity.class); Intent.putextra (Extra.images, Imageurls); Intent.putextra (Extra.image_position, POSITION); startactivity (intent);} private static class Viewholder {TextView text;imageview image;} Class Itemadapter extends Baseadapter {private Imageloadinglistener Animatefirstlistener = new Animatefirstdisplaylistener (); @Overridepublic int GetCount () {return imageurls.length;} @Overridepublic Object getItem (int position) {return position;} @Overridepublic long Getitemid (int position) {return position;} @Overridepublic View GetView (final int position, view Convertview, ViewGroup parent) {View view = Convertview;final viewho Lder holder;if (Convertview = = null) {view = Getlayoutinflater (). Inflate (R.layout.item_list_image, parent,FALSE); holder = new Viewholder (); holder.text = (TextView) View.findviewbyid (r.id.text); holder.image = (ImageView) View.findviewbyid (R.id.image); View.settag (holder);} else {holder = (Viewholder) View.gettag ();} Holder.text.setText ("Item" + (position + 1)); Imageloader.displayimage (Imageurls[position], holder.image, Options, Animatefirstlistener); return view;}} private static class Animatefirstdisplaylistener extends Simpleimageloadinglistener {static final list<string> Displayedimages = collections.synchronizedlist (New linkedlist<string> ()); @Overridepublic void Onloadingcomplete (String Imageuri, view view, Bitmap loadedimage) {if (loadedimage! = null) {ImageView ImageView = (Imagev Iew) View;boolean Firstdisplay =!displayedimages.contains (Imageuri), if (Firstdisplay) { Fadeinbitmapdisplayer.animate (ImageView, $);d Isplayedimages.add (Imageuri);}}}}
This is a demo, this picture option is best configured as a single-column class, easy to manage and reduce memory overflow.