List of usage examples for android.provider ContactsContract DEFERRED_SNIPPETING_QUERY
String DEFERRED_SNIPPETING_QUERY
To view the source code for android.provider ContactsContract DEFERRED_SNIPPETING_QUERY.
Click Source Link
From source file:com.android.contacts.common.list.ContactListItemView.java
/** * Shows search snippet.// ww w . j a v a 2 s . c o m */ public void showSnippet(Cursor cursor, int summarySnippetColumnIndex) { if (cursor.getColumnCount() <= summarySnippetColumnIndex || !SearchSnippets.SNIPPET.equals(cursor.getColumnName(summarySnippetColumnIndex))) { setSnippet(null); return; } String snippet = cursor.getString(summarySnippetColumnIndex); // Do client side snippeting if provider didn't do it final Bundle extras = cursor.getExtras(); if (extras.getBoolean(ContactsContract.DEFERRED_SNIPPETING)) { final String query = extras.getString(ContactsContract.DEFERRED_SNIPPETING_QUERY); String displayName = null; int displayNameIndex = cursor.getColumnIndex(Contacts.DISPLAY_NAME); if (displayNameIndex >= 0) { displayName = cursor.getString(displayNameIndex); } snippet = updateSnippet(snippet, query, displayName); } else { if (snippet != null) { int from = 0; int to = snippet.length(); int start = snippet.indexOf(DefaultContactListAdapter.SNIPPET_START_MATCH); if (start == -1) { snippet = null; } else { int firstNl = snippet.lastIndexOf('\n', start); if (firstNl != -1) { from = firstNl + 1; } int end = snippet.lastIndexOf(DefaultContactListAdapter.SNIPPET_END_MATCH); if (end != -1) { int lastNl = snippet.indexOf('\n', end); if (lastNl != -1) { to = lastNl; } } StringBuilder sb = new StringBuilder(); for (int i = from; i < to; i++) { char c = snippet.charAt(i); if (c != DefaultContactListAdapter.SNIPPET_START_MATCH && c != DefaultContactListAdapter.SNIPPET_END_MATCH) { sb.append(c); } } snippet = sb.toString(); } } } setSnippet(snippet); }