From 904f70c6f20b391ec12912acb6a66526aa467af9 Mon Sep 17 00:00:00 2001 From: Alexey Kulish Date: Wed, 29 Mar 2017 11:48:46 +0300 Subject: [PATCH] Fix creator --- .../src/net/osmand/search/SearchUICore.java | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/OsmAnd-java/src/net/osmand/search/SearchUICore.java b/OsmAnd-java/src/net/osmand/search/SearchUICore.java index ba1e69e196..85bc84f89c 100644 --- a/OsmAnd-java/src/net/osmand/search/SearchUICore.java +++ b/OsmAnd-java/src/net/osmand/search/SearchUICore.java @@ -47,6 +47,8 @@ public class SearchUICore { private ThreadPoolExecutor singleThreadedExecutor; private LinkedBlockingQueue taskQueue; + private Runnable onSearchStart = null; + private Runnable onResultsComplete = null; private AtomicInteger requestNumber = new AtomicInteger(); private int totalLimit = -1; // -1 unlimited - not used @@ -306,6 +308,14 @@ public class SearchUICore { return phrase; } + public void setOnSearchStart(Runnable onSearchStart) { + this.onSearchStart = onSearchStart; + } + + public void setOnResultsComplete(Runnable onResultsComplete) { + this.onResultsComplete = onResultsComplete; + } + public SearchSettings getSearchSettings() { return searchSettings; } @@ -356,6 +366,9 @@ public class SearchUICore { @Override public void run() { try { + if (onSearchStart != null) { + onSearchStart.run(); + } SearchResultMatcher rm = new SearchResultMatcher(matcher, phrase, request, requestNumber, totalLimit); rm.searchStarted(phrase); if (TIMEOUT_BETWEEN_CHARS > 0 && delayedExecution) { @@ -374,6 +387,9 @@ public class SearchUICore { LOG.info(">> Search phrase " + phrase + " " + rm.getRequestResults().size()); currentSearchResult = collection; rm.searchFinished(phrase); + if (onResultsComplete != null) { + onResultsComplete.run(); + } } } catch (InterruptedException e) { e.printStackTrace();