From c1c02a1076945454780b986678116da2fa9f8e2c Mon Sep 17 00:00:00 2001 From: Alexey Kulish Date: Mon, 8 Aug 2016 18:44:12 +0300 Subject: [PATCH] [Quick search] stable search for all types --- .../plus/search/QuickSearchDialogFragment.java | 18 +++++------------- 1 file changed, 5 insertions(+), 13 deletions(-) diff --git a/OsmAnd/src/net/osmand/plus/search/QuickSearchDialogFragment.java b/OsmAnd/src/net/osmand/plus/search/QuickSearchDialogFragment.java index 7b87ab3b04..85756622e4 100644 --- a/OsmAnd/src/net/osmand/plus/search/QuickSearchDialogFragment.java +++ b/OsmAnd/src/net/osmand/plus/search/QuickSearchDialogFragment.java @@ -854,7 +854,7 @@ public class QuickSearchDialogFragment extends DialogFragment implements OsmAndC final SearchPhrase regionPhrase = object.requiredSearchPhrase; regionResultCollection = new SearchResultCollection(regionPhrase).addSearchResults(results, true, true); - showRegionResults(regionPhrase, regionResultCollection); + showRegionResults(regionResultCollection); break; case PARTIAL_LOCATION: showLocationToolbar(); @@ -873,7 +873,7 @@ public class QuickSearchDialogFragment extends DialogFragment implements OsmAndC } }); - if (!searchMore || !needAppend(c.getPhrase())) { + if (!searchMore) { setResultCollection(null); updateSearchResult(null, false); } @@ -898,7 +898,7 @@ public class QuickSearchDialogFragment extends DialogFragment implements OsmAndC @Override public void run() { if (!paused) { - boolean append = needAppend(phrase); + boolean append = getResultCollection() != null; if (append) { getResultCollection().addSearchResults(apiResults, false, true); } else { @@ -914,13 +914,12 @@ public class QuickSearchDialogFragment extends DialogFragment implements OsmAndC }); } - private void showRegionResults(final SearchPhrase regionPhrase, final SearchResultCollection regionResultCollection) { + private void showRegionResults(final SearchResultCollection regionResultCollection) { app.runInUIThread(new Runnable() { @Override public void run() { if (!paused) { - boolean append = needAppend(regionPhrase); - if (append) { + if (getResultCollection() != null) { SearchResultCollection resCollection = getResultCollection().combineWithCollection(regionResultCollection, false, true); updateSearchResult(resCollection, true); @@ -932,13 +931,6 @@ public class QuickSearchDialogFragment extends DialogFragment implements OsmAndC }); } - private boolean needAppend(SearchPhrase phrase) { - return getResultCollection() != null && (getResultCollection().getPhrase() == phrase - || (getResultCollection().getPhrase().isLastWord(ObjectType.POI_TYPE) && phrase.isLastWord(ObjectType.POI_TYPE) - && getResultCollection().getPhrase().getLastSelectedWord().getWord().equals(phrase.getLastSelectedWord().getWord()) - && !getResultCollection().getPhrase().isUnknownSearchWordPresent() && !phrase.isUnknownSearchWordPresent())); - } - public void completeQueryWithObject(SearchResult sr) { searchUICore.selectSearchResult(sr); String txt = searchUICore.getPhrase().getText(true);