Contacts resolve

显示联系人
相关类
packages/apps/Contacts/src/com/android/contacts/activities/PeopleActivity.java
packages/apps/Contacts/src/com/android/contacts/list/DefaultContactBrowseListFragment.java
packages/apps/Contacts/src/com/android/contacts/list/DefaultContactListAdapter.java
packages/apps/Contacts/src/com/android/contacts/list/ContactEntryListFragment.java
packages/apps/Contacts/src/com/android/contacts/list/ContactEntryListAdapter.java
packages/apps/Contacts/src/com/android/contacts/list/DirectoryPartition.java
packages/apps/Contacts/src/com/android/contacts/list/DirectoryListLoader.java
packages/apps/Contacts/src/com/android/contacts/quickcontact/QuickContactActivity.java
packages/apps/Contacts/src/com/android/contacts/model/ContactLoader.java

Contact list data loading process

 


Open the AndroidManifest.xml file in the root directory of the Contacts view PeopleActivity attributes are as follows:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
<activity
android:name=".activities.PeopleActivity"
android:alwaysRetainTaskState="true"
android:launchMode="singleTop"
android:resizeableActivity="true"
android:theme="@style/LaunchScreenTheme"
android:visibleToInstantApps="true"
>
<intent-filter>
<action android:name="android.intent.action.MAIN"/>
<category android:name="android.intent.category.DEFAULT"/>
<category android:name="android.intent.category.LAUNCHER"/>
<category Android: name = "android.intent.category.BROWSABLE" />
<category Android: name = "android.intent.category.APP_CONTACTS" />
</ filter-Intent>
PeopleActivity is LAUNCHER Contacts application interface, thus opening contacts application, first load PeopleActivity, create a contact interface in createViewsAndFragments () method

Creating DefaultContactBrowseListFragment all contacts setUpListFragment () method Fragment

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
private void setUpListFragment(FragmentManager fragmentManager) {
mContactsListFragment = (DefaultContactBrowseListFragment)
fragmentManager.findFragmentByTag(TAG_ALL);
//判断mContactsListFragment为空则创建Fragment
if (mContactsListFragment == null) {
mContactsListFragment = new DefaultContactBrowseListFragment();
mContactsListFragment.setAnimateOnLoad(true);
fragmentManager.beginTransaction()
.add(R.id.contacts_list_container, mContactsListFragment, TAG_ALL)
.commit ();
fragmentManager.executePendingTransactions ();
}
// initialize a series of Fragment disposed
mContactsListFragment.setContactsAvailable (areContactsAvailable ());
mContactsListFragment.setListType (mContactListFilterController.getFilterListType ());
mContactsListFragment.setParameters (/ * * ContactsRequest / mrequest,
; / * * fromOnNewIntent / to false)
}
for all of the contact interfaces created after data loading, data is loaded using DirectoryListLoader, inherited from the loader system loader AsyncTaskLoader

DirectoryListLoader Uri does not load data from DirectoryPartition.mContentUri, but directly from the Directory category ContactContacts

. 1
2
. 3
. 4
. 5
. 6
. 7
. 8
. 9
10
. 11
12 is
13 is
14
15
16
. 17
18 is
. 19
20 is
21 is
22 is
23 is
24
25
26 is
27
28
29
30
Private Final static class DirectoryQuery {
// query data collation
public static final String ORDER_BY = Directory. _ID;
// query rules
public static Final String [] = {PROJECTION
Directory._ID,
Directory.PACKAGE_NAME,
Directory.TYPE_RESOURCE_ID,
Directory.DISPLAY_NAME,
Directory.PHOTO_SUPPORT,
};
static int ID = Final public 0;
public static int PACKAGE_NAME = Final. 1;
public static int TYPE_RESOURCE_ID Final = 2;
public static int DISPLAY_NAME = Final. 3;
public static int PHOTO_SUPPORT = Final. 4;
// Uri acquiring a query, the tracking code can be seen, Directory.ENTERPRISE_CONTENT_URI Android 25 after the release of only joined
//ContactsUtils.java
// public static Boolean FLAG_N_FEATURE = Final Build.VERSION.SDK_INT> = 24;
public static Uri getDirectoryUri (int MODE) {
IF (MODE == SEARCH_MODE_DATA_SHORTCUT || == SEARCH_MODE_CONTACT_SHORTCUT MODE) {
return Directory.CONTENT_URI;
} the else {
return DirectoryCompat.getContentUri ();
}
}
}
DirectoryPartition data loading process based on the contact information in the cache memory package after the management, load contact information, internal It provides three data load status information

1
2
3
public static int STATUS_NOT_LOADED Final = 0; // load the data has not been
public static final int STATUS_LOADING = 1; // data is being loaded
public static final int STATUS_LOADED = 2; // data has been loaded
contact details page loading process


Contact details of the interface class is QuickContactActivity, general contact details through other portals started, when you start to QuickContactActivity lookupUri must be passed by Intent, or they will call the finish () to close the screen

Loader ContactLoader list and contact details of the data loading process as are inherited from AsyncTaskLoader, can look at the code to understand

. 1
2
. 3
. 4
. 5
. 6
. 7
. 8
. 9
10
. 11
12 is
13 is
14
15
16
. 17
18 is
. 19
20 is
21 is
22 is
23 is
24
25
Private void processIntent (the Intent Intent) {
// Here various call finish determination (), is to be loaded contacts after the failure to determine the legality of their own to close the screen
......
// use oldLookupUri, to load the cache had contacts to open once again be able to load faster
mLookupUri = lookupUri;
mExcludeMimes = intent.getStringArrayExtra (QuickContact.EXTRA_EXCLUDE_MIMES) ;
IF (oldLookupUri == null) {
// Should Not only log IF Orientation Changes.
mShouldLog = mIsRecreatedInstance!;
mContactLoader = (ContactLoader) getLoaderManager().initLoader(
LOADER_CONTACT_ID, null, mLoaderContactCallbacks);
} else if (oldLookupUri != mLookupUri) {
// Should log when reload happens, regardless of orientation change.
mShouldLog = true;
// After copying a directory contact, the contact URI changes. Therefore,
// we need to reload the new contact.
destroyInteractionLoaders(http://www.amjmh.com/v/BIBRGZ_558768/);
mContactLoader = (ContactLoader) (Loader<?>) getLoaderManager().getLoader(
LOADER_CONTACT_ID);
mContactLoader.setNewLookup(mLookupUri);
mCachedCp2DataCardModel = null;
}
//最后通过ContactLoader开启联系人数据加载
mContactLoader.forceLoad();
}
————————————————

Guess you like

Origin www.cnblogs.com/ly570/p/11414321.html