public void setDisplayName(CharSequence name, boolean highlight) { if (!TextUtils.isEmpty(name) && highlight) { clearHighlightSequences(); addNameHighlightSequence(0, name.length()); } setDisplayName(name); }
/** * Sets highlight options for a List item in the SmartDial search results. * @param view ContactListItemView where the result will be displayed. * @param cursor Object containing information of the associated List item. */ @Override protected void setHighlight(ContactListItemView view, Cursor cursor) { view.clearHighlightSequences(); if (mNameMatcher.matches(cursor.getString(PhoneQuery.DISPLAY_NAME))) { final ArrayList<SmartDialMatchPosition> nameMatches = mNameMatcher.getMatchPositions(); for (SmartDialMatchPosition match:nameMatches) { view.addNameHighlightSequence(match.start, match.end); if (DEBUG) { Log.v(TAG, cursor.getString(PhoneQuery.DISPLAY_NAME) + " " + mNameMatcher.getQuery() + " " + String.valueOf(match.start)); } } } final SmartDialMatchPosition numberMatch = mNameMatcher.matchesNumber(cursor.getString( PhoneQuery.PHONE_NUMBER)); if (numberMatch != null) { view.addNumberHighlightSequence(numberMatch.start, numberMatch.end); } }