This code is based on the MTK platform Android 4.4.2 as the Analysis object, and Google native Aosp a little difference, please read the reader.
Android Contact list thumbnail loading is mainly used to Contactphotomanager.java this class, which is an abstract class, the implementation of the ComponentCallbacks2 interface, which has a specific implementation of its class, called Contactphotomanagerimpl,Contactphotomanagerimpl inherited theContactphotomanager and implements the Android.os.Handler.Callback interface, which mainly uses pre-load, asynchronous query and two LRUCacheCacheObjects (Mbitmapholdercache and Mbitmapcache)to improve the display speed of thumbnails, for the use of the LRUCache class, you can view the official Android document caching BitmapsOr a Chinese translation version. This article mainly understandof the thumbnail imagepreload (contact.apk starts when it is loaded, exactly when the Contact Favorites page (contacttilelistfragment) is loaded), the asynchronous query process (using GetView () on the thumbnail when the ListView is displayed) The loading process is similar to preloading).
pre-loading process is mainly concerned about the change of loading state mpreloadstatus is more easily understood,
private static final int preload_status_not_started = 0; Preload has not started private static final int preload_status_in_progress = 1;//preload in private static final int preload_stat Us_done = 2; Pre-loading complete
Step16,queryphotosforpreload () Query the Contact table of contact2.db, find the photo_id of contacts with thumbnails, preload up to load Max_photos_to_preload bar,
/** * Maximum number of photos to preload. If the cache size is 2Mb and * The expected average size of a photo are 4kb, then this number should be 2MB/4KB = 500.< c9/>*/ private static final int max_photos_to_preload = 100;
Put the queried photo_id into the preload list mpreloadphotoids.
STEP19,
int preloadsize = Mpreloadphotoids.size (); while (preloadsize > 0 && mphotoids.size () < Preload_batch) { preloadsize--; count++; Long photoid = Mpreloadphotoids.get (preloadsize); Mphotoids.add (photoid); Mphotoidsasstrings.add (Photoid.tostring ()); Mpreloadphotoids.remove (preloadsize); }
To Mphotoids and mphotoidsasstrings assignment, rule situation source code.
step20,loadthumbnails () will use the above two sets, query the data table again, the thumbnail query out. STEP24 will cache thumbnails to LRUCache objects Mbitmapholdercache
Impatient to get off work, don't say ...
Right-copy the image address and open it in the browser to see a larger image.
Please correct me if there is any wrong place to be continued.
Android4.4 Telephony Process Analysis--contact list thumbnail loading process