Android Open source project Universal Imageloader Source research project Framework

Source: Internet
Author: User

Universal Imageloader code is not complicated. Focus on caching, thread pool tasks

The following are plotted with UML diagrams

The basic usage process is to initialize the configuration, set the options parameters, and finally dispaly submit the download

     Public Static voidInitimageloader (Context context) {Imageloaderconfiguration.builder config =NewImageloaderconfiguration.builder (context); Config.threadpriority (thread.norm_priority-2);        Config.denycacheimagemultiplesizesinmemory (); Config.diskcachefilenamegenerator (Newmd5filenamegenerator ()); Config.diskcachesize (50 * 1024 * 1024);//MiBConfig.tasksprocessingorder (QUEUEPROCESSINGTYPE.LIFO); Config.writedebuglogs ();//Initialize imageloader with configuration.imageloader.getinstance (). Init (Config.build ()); }

            New Displayimageoptions.builder ()                    . showimageonloading (r.drawable.ic_stub)                    . Showimageforemptyuri ( R.drawable.ic_empty)                    . Showimageonfail (R.drawable.ic_error)                    . Cacheinmemory (true)                    . Cacheondisk (True).                    Considerexifparams (true)                    . Bitmapconfig (Bitmap.Config.RGB_565)                    . Build ();

imageloader.getinstance (). DisplayImage (Image_urls[0], Holder.imageview, options,NewSimpleimageloadinglistener () {@Override Public voidonloadingstarted (String imageuri, view view) {} @Override Public voidonloadingfailed (String imageuri, view view, Failreason Failreason) { } @Override Public voidOnloadingcomplete (String imageuri, view view, Bitmap loadedimage) { }                    }, NewImageloadingprogresslistener () {@Override Public voidOnprogressupdate (String Imageuri, view view,intCurrentintTotal ) {                                                   }                    });

Imageloader is the entrance, and other classes include config and option. Imageloaderengine for engines, others including wrappers, network downloads and decoding

Disk caching and memory caching, including several classic algorithm implementations.

Imageloader callback There is no bitmap data provided just bitmap set to ImageView object directly

Bitmapprocessor can be handled via interface

Options =NewDisplayimageoptions.builder ().                Preprocessor (preprocessor). Postprocessor (postprocessor);//before entering the cacheBitmapprocessor preprocessor =Newbitmapprocessor () {@Override PublicBitmap Process (Bitmap Bitmap) {return NULL;        }            }; //processed before showing to ImageViewBitmapprocessor postprocessor =Newbitmapprocessor () {@Override PublicBitmap Process (Bitmap Bitmap) {return NULL; }            };

Android Open source project Universal Imageloader Source research project Framework

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.