diff --git a/android/res/values/colors.xml b/android/res/values/colors.xml index 0178d1261c..2d54c4b738 100644 --- a/android/res/values/colors.xml +++ b/android/res/values/colors.xml @@ -63,4 +63,8 @@ + + @color/text_green + + diff --git a/android/src/com/mapswithme/maps/search/SearchAdapter.java b/android/src/com/mapswithme/maps/search/SearchAdapter.java index 6747f2200f..47a205c091 100644 --- a/android/src/com/mapswithme/maps/search/SearchAdapter.java +++ b/android/src/com/mapswithme/maps/search/SearchAdapter.java @@ -102,36 +102,33 @@ public class SearchAdapter extends RecyclerView.Adapter 0) { - if (result.mHighlightRanges.length > 0) + int j = 0, n = result.mHighlightRanges.length / 2; + + for (int i = 0; i < n; ++i) { - int j = 0, n = result.mHighlightRanges.length / 2; + int start = result.mHighlightRanges[j++]; + int len = result.mHighlightRanges[j++]; - for (int i = 0; i < n; ++i) - { - int start = result.mHighlightRanges[j++]; - int len = result.mHighlightRanges[j++]; - - builder.setSpan(new StyleSpan(Typeface.BOLD), start, start + len, Spanned.SPAN_EXCLUSIVE_EXCLUSIVE); - } + builder.setSpan(new StyleSpan(Typeface.BOLD), start, start + len, Spanned.SPAN_EXCLUSIVE_EXCLUSIVE); } - else - builder.clearSpans(); + } - country = result.mCountry; - dist = result.mDistance; + if (result.mType == SearchResult.TYPE_SUGGESTION) + { + builder.setSpan(new ForegroundColorSpan(mResources.getColor(R.color.text_search_suggestion)), 0, builder.length(), Spanned.SPAN_EXCLUSIVE_EXCLUSIVE); + UiUtils.hide(holder.mCountry, holder.mDistance); } else - builder.setSpan(new ForegroundColorSpan(mResources.getColor(R.color.text_green)), 0, builder.length(), Spanned.SPAN_EXCLUSIVE_EXCLUSIVE); + { + UiUtils.setTextAndHideIfEmpty(holder.mCountry, result.mCountry); + UiUtils.setTextAndHideIfEmpty(holder.mDistance, result.mDistance); + } UiUtils.setTextAndShow(holder.mName, builder); - UiUtils.setTextAndHideIfEmpty(holder.mCountry, country); UiUtils.setTextAndHideIfEmpty(holder.mType, result.mAmenity); - UiUtils.setTextAndHideIfEmpty(holder.mDistance, dist); } } diff --git a/android/src/com/mapswithme/maps/search/SearchResult.java b/android/src/com/mapswithme/maps/search/SearchResult.java index 78da1aa61b..fb3bb32f77 100644 --- a/android/src/com/mapswithme/maps/search/SearchResult.java +++ b/android/src/com/mapswithme/maps/search/SearchResult.java @@ -17,7 +17,7 @@ public class SearchResult public static final int TYPE_FEATURE = 1; public int mType; - // consecutive pairs of indexes (each pair contains : start index, length), specifying highlighted substrings of original query + // consecutive pairs of indexes (each pair contains : start index, length), specifying highlighted matches of original query in result public int[] mHighlightRanges; public SearchResult(String name, String suggestion, int[] highlightRanges)