From 2ff5416c94490ee23834afc0711f1b6cb2346b65 Mon Sep 17 00:00:00 2001 From: Alexander Sytnyk Date: Wed, 19 Jul 2017 12:07:51 +0300 Subject: [PATCH 1/2] Fix #3805 --- OsmAnd-java/src/net/osmand/search/SearchUICore.java | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/OsmAnd-java/src/net/osmand/search/SearchUICore.java b/OsmAnd-java/src/net/osmand/search/SearchUICore.java index 56828d62b2..94e88b1e55 100644 --- a/OsmAnd-java/src/net/osmand/search/SearchUICore.java +++ b/OsmAnd-java/src/net/osmand/search/SearchUICore.java @@ -372,7 +372,12 @@ public class SearchUICore { SearchResultMatcher rm = new SearchResultMatcher(matcher, phrase, request, requestNumber, totalLimit); rm.searchStarted(phrase); if (TIMEOUT_BETWEEN_CHARS > 0 && delayedExecution) { - Thread.sleep(TIMEOUT_BETWEEN_CHARS); + long startTime = System.currentTimeMillis(); + while (System.currentTimeMillis() - startTime <= TIMEOUT_BETWEEN_CHARS) { + if (rm.isCancelled()) { + return; + } + } } else if (TIMEOUT_BEFORE_SEARCH > 0) { Thread.sleep(TIMEOUT_BEFORE_SEARCH); } From 2baa8d65944e4a5be9d426c9bf78bd4024c4d564 Mon Sep 17 00:00:00 2001 From: Alexander Sytnyk Date: Wed, 19 Jul 2017 12:11:16 +0300 Subject: [PATCH 2/2] Add sleep --- OsmAnd-java/src/net/osmand/search/SearchUICore.java | 1 + 1 file changed, 1 insertion(+) diff --git a/OsmAnd-java/src/net/osmand/search/SearchUICore.java b/OsmAnd-java/src/net/osmand/search/SearchUICore.java index 94e88b1e55..b0a98941fc 100644 --- a/OsmAnd-java/src/net/osmand/search/SearchUICore.java +++ b/OsmAnd-java/src/net/osmand/search/SearchUICore.java @@ -377,6 +377,7 @@ public class SearchUICore { if (rm.isCancelled()) { return; } + Thread.sleep(TIMEOUT_BEFORE_SEARCH); } } else if (TIMEOUT_BEFORE_SEARCH > 0) { Thread.sleep(TIMEOUT_BEFORE_SEARCH);