diff --git a/OsmAnd/src/net/osmand/plus/settings/fragments/search/PreferencePathDisplayer.java b/OsmAnd/src/net/osmand/plus/settings/fragments/search/PreferencePathDisplayer.java index ca63803f9a2..26a85a6b361 100644 --- a/OsmAnd/src/net/osmand/plus/settings/fragments/search/PreferencePathDisplayer.java +++ b/OsmAnd/src/net/osmand/plus/settings/fragments/search/PreferencePathDisplayer.java @@ -37,15 +37,9 @@ private static List getTitles(final PreferencePath preferencePa return preferencePath .preferences() .stream() - .map(PreferencePathDisplayer::getTitle) - .collect(Collectors.toList()); - } - - private static SpannableString getTitle(final SearchablePreferencePOJO searchablePreferencePOJO) { - return searchablePreferencePOJO - .getTitle() + .map(preference -> preference.getTitle().orElse("?")) .map(SpannableString::new) - .orElseGet(() -> new SpannableString("?")); + .collect(Collectors.toList()); } private void highlightApplicationModeAtStartOfLongPreferencePath(final PreferencePath preferencePath, final List titles) { @@ -69,19 +63,19 @@ private void highlight(final Spannable spannable) { Spannable.SPAN_EXCLUSIVE_EXCLUSIVE); } - private static SpannableString join(final List titles, final SpannableString delimiter) { - return appendAll(insert(titles, delimiter)); + private static SpannableString join(final List strings, final SpannableString delimiter) { + return concat(insertDelimiterBetweenElements(strings, delimiter)); } - private static List insert(final List ts, final T delimiter) { - return ts + private static List insertDelimiterBetweenElements(final List elements, final T delimiter) { + return elements .stream() .flatMap(t -> Stream.of(t, delimiter)) - .limit(ts.size() * 2L - 1) + .limit(elements.size() * 2L - 1) .collect(Collectors.toList()); } - private static SpannableString appendAll(final List charSequences) { + private static SpannableString concat(final List charSequences) { final SpannableStringBuilder builder = new SpannableStringBuilder(); charSequences.forEach(builder::append); return new SpannableString(builder);