diff --git a/android/jni/com/mapswithme/maps/SearchEngine.cpp b/android/jni/com/mapswithme/maps/SearchEngine.cpp index 18eb845620..32ef619608 100644 --- a/android/jni/com/mapswithme/maps/SearchEngine.cpp +++ b/android/jni/com/mapswithme/maps/SearchEngine.cpp @@ -508,6 +508,15 @@ extern "C" }); } + JNIEXPORT void JNICALL + Java_com_mapswithme_maps_search_SearchEngine_nativeCancelAllSearches(JNIEnv * env, jclass clazz) + { + GetPlatform().RunOnGuiThread([]() + { + g_framework->NativeFramework()->CancelAllSearches(); + }); + } + JNIEXPORT jobjectArray JNICALL Java_com_mapswithme_maps_search_SearchEngine_nativeGetHotelTypes(JNIEnv * env, jclass clazz) { diff --git a/android/src/com/mapswithme/maps/MwmActivity.java b/android/src/com/mapswithme/maps/MwmActivity.java index a9323dbe31..f9a1bc9864 100644 --- a/android/src/com/mapswithme/maps/MwmActivity.java +++ b/android/src/com/mapswithme/maps/MwmActivity.java @@ -461,7 +461,7 @@ public class MwmActivity extends BaseMwmFragmentActivity args.putBoolean(DownloaderActivity.EXTRA_OPEN_DOWNLOADED, openDownloaded); if (mIsFragmentContainer) { - SearchEngine.cancelInteractiveSearch(); + SearchEngine.cancelAllSearches(); mSearchController.refreshToolbar(); replaceFragment(MapManager.nativeIsLegacyMode() ? MigrationFragment.class : DownloaderFragment.class, args, null); } diff --git a/android/src/com/mapswithme/maps/search/SearchEngine.java b/android/src/com/mapswithme/maps/search/SearchEngine.java index 69f3bb5914..4d715478ec 100644 --- a/android/src/com/mapswithme/maps/search/SearchEngine.java +++ b/android/src/com/mapswithme/maps/search/SearchEngine.java @@ -156,6 +156,12 @@ public enum SearchEngine implements NativeSearchListener, nativeCancelEverywhereSearch(); } + public static void cancelAllSearches() + { + sSavedQuery = ""; + nativeCancelAllSearches(); + } + public static void showResult(int index) { sSavedQuery = ""; @@ -191,6 +197,8 @@ public enum SearchEngine implements NativeSearchListener, public static native void nativeCancelEverywhereSearch(); + public static native void nativeCancelAllSearches(); + /** * @return all existing hotel types */ diff --git a/android/src/com/mapswithme/maps/search/SearchFragment.java b/android/src/com/mapswithme/maps/search/SearchFragment.java index 1ea2a2d147..ff443d599c 100644 --- a/android/src/com/mapswithme/maps/search/SearchFragment.java +++ b/android/src/com/mapswithme/maps/search/SearchFragment.java @@ -534,7 +534,7 @@ public class SearchFragment extends BaseMwmFragment private void stopSearch() { SearchEngine.cancelApiCall(); - SearchEngine.cancelInteractiveSearch(); + SearchEngine.cancelAllSearches(); onSearchEnd(); } diff --git a/search/geocoder.cpp b/search/geocoder.cpp index b3eb77a576..385bd4b8b0 100644 --- a/search/geocoder.cpp +++ b/search/geocoder.cpp @@ -43,6 +43,7 @@ #include "std/algorithm.hpp" #include "std/bind.hpp" #include "std/iterator.hpp" +#include "std/random.hpp" #include "std/sstream.hpp" #include "std/transform_iterator.hpp" #include "std/unique_ptr.hpp" @@ -321,7 +322,7 @@ CBV DecimateCianResults(CBV const & cbv) // Leaving only a fraction of them does not seem // to worsen the percieved result. size_t const kMaxCianResults = 10000; - static minstd_rand rng; + minstd_rand rng(0); auto survivedIds = base::RandomSample(cbv.PopCount(), kMaxCianResults, rng); sort(survivedIds.begin(), survivedIds.end()); auto it = survivedIds.begin();