Android4.4 Telephony process analysis-the loading process of the Contact list thumbnail, android4.4

Source: Internet
Author: User

Android4.4 Telephony process analysis-the loading process of the Contact list thumbnail, android4.4

The code in this article takes the MTK platform Android 4.4.2 as the analysis object, which is somewhat different from Google's native AOSP. Please be aware of it.


ContactPhotoManager is used to load thumbnails of the Android contact list. java class. This is an abstract class that implements the ComponentCallbacks2 interface. It has a specific implementation class called ContactPhotoManagerImpl. ContactPhotoManagerImpl inherits ContactPhotoManager and implements android. OS. handler. callback interface, which mainly uses preload, asynchronous query, and two LruCache cache objects (mBitmapHolderCache and mBitmapCache) to increase the display speed of thumbnails, you can view the official Android document Caching Bitmaps or the Chinese translation version. This document mainly describes how to load the preview (contact.apk when it is started, specifically when the ContactTileListFragment page is loaded) and asynchronous Query Process (getView () is used when the ListView is displayed () the process of loading thumbnails is similar to that of pre-loading ).



The pre-loading process focuses on the changes in the loading status mPreloadStatus, which is easier to understand,

Private static final int PRELOAD_STATUS_NOT_STARTED = 0; // pre-loading has not started private static final int PRELOAD_STATUS_IN_PROGRESS = 1; // private static final int PRELOAD_STATUS_DONE = 2; // pre-Load completed
In step 16, queryPhotosForPreload (), query the contact table of contact2.db, find the PHOTO_ID of the contact with a thumbnail, and load a maximum of MAX_PHOTOS_TO_PRELOAD entries by preload,

        /**         * Maximum number of photos to preload.  If the cache size is 2Mb and         * the expected average size of a photo is 4kb, then this number should be 2Mb/4kb = 500.         */        private static final int MAX_PHOTOS_TO_PRELOAD = 100;

Put the queried PHOTO_ID in the pre-loaded list mPreloadPhotoIds.

Step 19,

            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);            }

Assign values to mPhotoIds and mPhotoIdsAsStrings, source code of the rules.

In step 20, loadThumbnails (), the above two sets are used. query the Data table again and query the thumbnail. Step 24 caches the thumbnail to the LruCache object mBitmapHolderCache.


I'm in a hurry to get off work...



Right-click the image address and open it in the browser to view the large image.

Not yet resumed. please correct me if there is anything wrong.



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.