From 170655ec320970b6dd90f42579cae41f9d2367ec Mon Sep 17 00:00:00 2001 From: crimean Date: Sun, 7 Apr 2019 19:17:41 +0300 Subject: [PATCH] Fix #6171 --- .../search/QuickSearchDialogFragment.java | 5 ++ .../plus/search/QuickSearchListFragment.java | 48 ++++--------------- 2 files changed, 13 insertions(+), 40 deletions(-) diff --git a/OsmAnd/src/net/osmand/plus/search/QuickSearchDialogFragment.java b/OsmAnd/src/net/osmand/plus/search/QuickSearchDialogFragment.java index 60805eb4bd..1db0042f89 100644 --- a/OsmAnd/src/net/osmand/plus/search/QuickSearchDialogFragment.java +++ b/OsmAnd/src/net/osmand/plus/search/QuickSearchDialogFragment.java @@ -916,6 +916,11 @@ public class QuickSearchDialogFragment extends DialogFragment implements OsmAndC @Override public boolean searchFinished(SearchPhrase phrase) { + SearchWord lastSelectedWord = phrase.getLastSelectedWord(); + if (mainSearchFragment != null && mainSearchFragment.isShowResult() && + isResultEmpty() && lastSelectedWord != null) { + mainSearchFragment.showResult(lastSelectedWord.getResult()); + } return true; } }; diff --git a/OsmAnd/src/net/osmand/plus/search/QuickSearchListFragment.java b/OsmAnd/src/net/osmand/plus/search/QuickSearchListFragment.java index ee010a9745..fa5e9f8363 100644 --- a/OsmAnd/src/net/osmand/plus/search/QuickSearchListFragment.java +++ b/OsmAnd/src/net/osmand/plus/search/QuickSearchListFragment.java @@ -11,8 +11,6 @@ import android.widget.ArrayAdapter; import android.widget.ListView; import net.osmand.GPXUtilities; -import net.osmand.ResultMatcher; -import net.osmand.binary.BinaryMapIndexReader; import net.osmand.data.Amenity; import net.osmand.data.City; import net.osmand.data.FavouritePoint; @@ -36,7 +34,6 @@ import net.osmand.search.core.ObjectType; import net.osmand.search.core.SearchResult; import net.osmand.util.Algorithms; -import java.io.IOException; import java.util.ArrayList; import java.util.List; @@ -46,6 +43,7 @@ public abstract class QuickSearchListFragment extends OsmAndListFragment { private QuickSearchListAdapter listAdapter; private boolean touching; private boolean scrolling; + private boolean showResult; enum SearchListFragmentType { HISTORY, @@ -101,13 +99,8 @@ public abstract class QuickSearchListFragment extends OsmAndListFragment { showResult(sr); } else { - if ((sr.objectType == ObjectType.CITY || sr.objectType == ObjectType.VILLAGE) - && sr.file != null && sr.object instanceof City) { - City c = (City) sr.object; - if (isCityEmpty(c, sr)) { - showResult(sr); - return; - } + if (sr.objectType == ObjectType.CITY || sr.objectType == ObjectType.VILLAGE) { + showResult = true; } dialogFragment.completeQueryWithObject(sr); } @@ -116,36 +109,6 @@ public abstract class QuickSearchListFragment extends OsmAndListFragment { } } - public boolean isCityEmpty(City c, SearchResult sr) { - final boolean isEmpty[] = new boolean[1]; - isEmpty[0] = true; - if (c.getStreets().isEmpty()) { - ResultMatcher resultMatcher = new ResultMatcher() { - boolean isCancelled = false; - - @Override - public boolean publish(Street object) { - isCancelled = true; - isEmpty[0] = false; - return false; - } - - @Override - public boolean isCancelled() { - return isCancelled; - } - }; - try { - sr.file.preloadStreets(c, BinaryMapIndexReader.buildAddressRequest(resultMatcher)); - } catch (IOException e) { - e.printStackTrace(); - } - } else { - isEmpty[0] = false; - } - return isEmpty[0]; - } - @Override public void onActivityCreated(Bundle savedInstanceState) { super.onActivityCreated(savedInstanceState); @@ -196,7 +159,12 @@ public abstract class QuickSearchListFragment extends OsmAndListFragment { dialogFragment.onSearchListFragmentResume(this); } + public boolean isShowResult() { + return showResult; + } + public void showResult(SearchResult searchResult) { + showResult = false; if (searchResult.location != null) { OsmandApplication app = getMyApplication(); String lang = searchResult.requiredSearchPhrase.getSettings().getLang();