1. Create a Imageloader object in singleton mode
2. Initialize LruCache(least recently using the algorithm's Cache tool class, http://www.cnblogs.com/tianzhijiexian/p/4248677.html), taking part of available memory to store pictures
3. Initialize disklrucache(HDD Cache)
4. Call the show Picture method
- If you use a resource ID, set the picture directly for ImageView
- Set tag as URL for ImageView
- LRUCache Memory cache Take picture, if there is picture, set picture, return
- Add the picture load request to the picture loading stack stack (LIFO), if the stack has the same request, delete it, and add the request to the top of the stack.
- To start sending a picture load request:
If the picture load thread is empty, initialize the picture load thread (using handlerthread and handler)
Loop : Take picture loading request from picture loading stack, load picture in picture loading handler
If it is a local picture, it is read directly, not read from Disklrucache, otherwise read from Disklrucache, if bitmap is not empty, add to LRUCache;
If it is a network picture, then load from the network, the process of loading, direct image compression , if the bitmap is not empty, added to the LRUCache and Disklrucache;
Notifies the UI thread to set bitmap for ImageView, determine whether the same imageview based on URL and tag, and then set the picture (to prevent image misalignment )
Continue Looping
Android Imageloader picture loading simple logic