summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBen Brosbe <benbro@google.com>2016-03-17 20:51:47 +0000
committerandroid-build-merger <android-build-merger@google.com>2016-03-17 20:51:47 +0000
commitbe4a519d52f362f29785d8564251c79636035c7e (patch)
tree9dba26a2c2c0a5dda4246ca5360b0e67f7527a21
parentc4cb18534ce7f3ed22737f59855caccba264f59b (diff)
parentbdadd6ac421d3af8b543153cb97834a4cec353d9 (diff)
downloadchips-be4a519d52f362f29785d8564251c79636035c7e.tar.gz
Merge "Allowing subclasses of DropdownChipLayouter to optionally have their own logic for styling string matches" into ub-chips-deer-lake
am: bdadd6a * commit 'bdadd6ac421d3af8b543153cb97834a4cec353d9': Allowing subclasses of DropdownChipLayouter to optionally have their own logic for styling string matches
-rw-r--r--src/com/android/ex/chips/DropdownChipLayouter.java19
1 files changed, 17 insertions, 2 deletions
diff --git a/src/com/android/ex/chips/DropdownChipLayouter.java b/src/com/android/ex/chips/DropdownChipLayouter.java
index b6f1c72..93e433a 100644
--- a/src/com/android/ex/chips/DropdownChipLayouter.java
+++ b/src/com/android/ex/chips/DropdownChipLayouter.java
@@ -117,8 +117,7 @@ public class DropdownChipLayouter {
public View bindView(View convertView, ViewGroup parent, RecipientEntry entry, int position,
AdapterType type, String constraint, StateListDrawable deleteDrawable) {
// Default to show all the information
- CharSequence[] styledResults =
- getStyledResults(constraint, entry.getDisplayName(), entry.getDestination());
+ CharSequence[] styledResults = getStyledResults(constraint, entry);
CharSequence displayName = styledResults[0];
CharSequence destination = styledResults[1];
boolean showImage = true;
@@ -454,6 +453,22 @@ public class DropdownChipLayouter {
}
/**
+ * Given a constraint and a recipient entry, tries to find the constraint in the name and
+ * destination in the recipient entry. A foreground font color style will be applied to the
+ * section that matches the constraint. As soon as a match has been found, no further matches
+ * are attempted.
+ *
+ * @param constraint A string that we will attempt to find within the results.
+ * @param entry The recipient entry to style results for.
+ *
+ * @return An array of CharSequences, the length determined by the length of results. Each
+ * CharSequence will either be a styled SpannableString or just the input String.
+ */
+ protected CharSequence[] getStyledResults(@Nullable String constraint, RecipientEntry entry) {
+ return getStyledResults(constraint, entry.getDisplayName(), entry.getDestination());
+ }
+
+ /**
* Given a constraint and results, tries to find the constraint in those results, one at a time.
* A foreground font color style will be applied to the section that matches the constraint. As
* soon as a match has been found, no further matches are attempted.