diff --git a/OsmAnd-java/src/net/osmand/search/SearchUICore.java b/OsmAnd-java/src/net/osmand/search/SearchUICore.java index 8ca902fdad..74d5c9a0bd 100644 --- a/OsmAnd-java/src/net/osmand/search/SearchUICore.java +++ b/OsmAnd-java/src/net/osmand/search/SearchUICore.java @@ -39,7 +39,8 @@ import java.util.concurrent.atomic.AtomicInteger; public class SearchUICore { - private static final int TIMEOUT_BETWEEN_CHARS = 400; + private static final int TIMEOUT_BETWEEN_CHARS = 700; + private static final int TIMEOUT_BEFORE_SEARCH = 50; private static final Log LOG = PlatformUtil.getLog(SearchUICore.class); private SearchPhrase phrase; private SearchResultCollection currentSearchResult; @@ -353,7 +354,7 @@ public class SearchUICore { return this.phrase; } - public SearchResultCollection search(final String text, final ResultMatcher matcher) { + public SearchResultCollection search(final String text, final boolean updateResult, final ResultMatcher matcher) { final int request = requestNumber.incrementAndGet(); final SearchPhrase phrase = this.phrase.generateNewPhrase(text, searchSettings); this.phrase = phrase; @@ -369,10 +370,12 @@ public class SearchUICore { onSearchStart.run(); } SearchResultMatcher rm = new SearchResultMatcher(matcher, phrase, request, requestNumber, totalLimit); - if(TIMEOUT_BETWEEN_CHARS > 0) { + if (TIMEOUT_BETWEEN_CHARS > 0 && updateResult) { Thread.sleep(TIMEOUT_BETWEEN_CHARS); + } else if (TIMEOUT_BEFORE_SEARCH > 0) { + Thread.sleep(TIMEOUT_BEFORE_SEARCH); } - if(rm.isCancelled()) { + if (rm.isCancelled()) { return; } searchInBackground(phrase, rm); diff --git a/OsmAnd/src/net/osmand/plus/search/QuickSearchDialogFragment.java b/OsmAnd/src/net/osmand/plus/search/QuickSearchDialogFragment.java index 2b7402839d..5c483b733a 100644 --- a/OsmAnd/src/net/osmand/plus/search/QuickSearchDialogFragment.java +++ b/OsmAnd/src/net/osmand/plus/search/QuickSearchDialogFragment.java @@ -1072,7 +1072,7 @@ public class QuickSearchDialogFragment extends DialogFragment implements OsmAndC searchEditText.setHint(R.string.type_city_town); startCitySearch(); updateTabbarVisibility(false); - runSearch(); + runCoreSearch("", false, false); searchEditText.requestFocus(); AndroidUtils.softKeyboardDelayed(searchEditText); } @@ -1249,7 +1249,7 @@ public class QuickSearchDialogFragment extends DialogFragment implements OsmAndC } private void runCoreSearchInternal(String text, boolean updateResult, boolean searchMore) { - SearchResultCollection c = searchUICore.search(text, new ResultMatcher() { + SearchResultCollection c = searchUICore.search(text, updateResult, new ResultMatcher() { SearchResultCollection regionResultCollection = null; SearchCoreAPI regionResultApi = null; List results = new ArrayList<>();