From dee64767977eabad0cb3c2e6dc79e366beaf07a7 Mon Sep 17 00:00:00 2001 From: Vitaliy Date: Tue, 12 May 2020 21:57:52 +0300 Subject: [PATCH] Remove unnecessary sort --- .../main/java/net/osmand/search/SearchUICore.java | 12 +++++++++--- .../plus/search/QuickSearchDialogFragment.java | 10 +--------- 2 files changed, 10 insertions(+), 12 deletions(-) diff --git a/OsmAnd-java/src/main/java/net/osmand/search/SearchUICore.java b/OsmAnd-java/src/main/java/net/osmand/search/SearchUICore.java index 5124d40cf4..89e422ec60 100644 --- a/OsmAnd-java/src/main/java/net/osmand/search/SearchUICore.java +++ b/OsmAnd-java/src/main/java/net/osmand/search/SearchUICore.java @@ -291,8 +291,14 @@ public class SearchUICore { return null; } - public SearchResultCollection shallowSearch(Class cl, - String text, final ResultMatcher matcher) throws IOException { + public SearchResultCollection shallowSearch(Class cl, String text, + ResultMatcher matcher) throws IOException { + return shallowSearch(cl, text, matcher, true, true); + } + + public SearchResultCollection shallowSearch(Class cl, String text, + final ResultMatcher matcher, + boolean resortAll, boolean removeDuplicates) throws IOException { T api = getApiByClass(cl); if (api != null) { if (debugMode) { @@ -306,7 +312,7 @@ public class SearchUICore { SearchResultCollection collection = new SearchResultCollection( sphrase); - collection.addSearchResults(rm.getRequestResults(), true, true); + collection.addSearchResults(rm.getRequestResults(), resortAll, removeDuplicates); if (debugMode) { LOG.info("Finish shallow search <" + sphrase + "> Results=" + rm.getRequestResults().size()); } diff --git a/OsmAnd/src/net/osmand/plus/search/QuickSearchDialogFragment.java b/OsmAnd/src/net/osmand/plus/search/QuickSearchDialogFragment.java index a316ffbf29..4637f95455 100644 --- a/OsmAnd/src/net/osmand/plus/search/QuickSearchDialogFragment.java +++ b/OsmAnd/src/net/osmand/plus/search/QuickSearchDialogFragment.java @@ -109,8 +109,6 @@ import net.osmand.util.MapUtils; import java.io.File; import java.io.IOException; import java.util.ArrayList; -import java.util.Collections; -import java.util.Comparator; import java.util.List; import static net.osmand.plus.poi.PoiFiltersHelper.PoiTemplateList; @@ -1509,18 +1507,12 @@ public class QuickSearchDialogFragment extends DialogFragment implements OsmAndC private void reloadHistoryInternal() { if (historySearchFragment != null) { try { - SearchResultCollection res = searchUICore.shallowSearch(SearchHistoryAPI.class, "", null); + SearchResultCollection res = searchUICore.shallowSearch(SearchHistoryAPI.class, "", null, false, false); List rows = new ArrayList<>(); if (res != null) { for (SearchResult sr : res.getCurrentSearchResults()) { rows.add(new QuickSearchListItem(app, sr)); } - Collections.sort(rows, new Comparator() { - @Override - public int compare(QuickSearchListItem o1, QuickSearchListItem o2) { - return Double.compare(o1.getSearchResult().priority, o2.getSearchResult().priority); - } - }); } historySearchFragment.updateListAdapter(rows, false); } catch (Exception e) {