Full text search: ignoring snippets without matches
Bug: 2078420
Change-Id: I1837a94c16d9f81ae36626f902e0853ec700cfa0
diff --git a/src/com/android/contacts/list/ContactListItemView.java b/src/com/android/contacts/list/ContactListItemView.java
index 121f90d..fe5f8e2 100644
--- a/src/com/android/contacts/list/ContactListItemView.java
+++ b/src/com/android/contacts/list/ContactListItemView.java
@@ -870,29 +870,31 @@
int from = 0;
int to = snippet.length();
int start = snippet.indexOf(DefaultContactListAdapter.SNIPPET_START_MATCH);
- if (start != -1) {
+ 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;
+ 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);
+ 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();
}
- snippet = sb.toString();
}
setSnippet(snippet);
}