From cc61b2aefca608028302121e0c913c9335eeb9b2 Mon Sep 17 00:00:00 2001 From: vng Date: Wed, 16 Dec 2015 21:03:43 +0300 Subject: [PATCH] [search] Restore interactive search after drape merge. --- .../jni/com/mapswithme/maps/SearchEngine.cpp | 2 +- map/framework.cpp | 27 +++++-------------- map/framework.hpp | 4 --- map/user_mark_container.cpp | 2 +- 4 files changed, 9 insertions(+), 26 deletions(-) diff --git a/android/jni/com/mapswithme/maps/SearchEngine.cpp b/android/jni/com/mapswithme/maps/SearchEngine.cpp index 63e23d0aa6..5221760836 100644 --- a/android/jni/com/mapswithme/maps/SearchEngine.cpp +++ b/android/jni/com/mapswithme/maps/SearchEngine.cpp @@ -212,7 +212,7 @@ extern "C" Java_com_mapswithme_maps_search_SearchEngine_nativeShowAllResults(JNIEnv * env, jclass clazz) { lock_guard guard(g_resultsMutex); - auto results = g_results; + auto const & results = g_results; g_framework->PostDrapeTask([results]() { g_framework->NativeFramework()->ShowAllSearchResults(results); diff --git a/map/framework.cpp b/map/framework.cpp index d69ded9b55..334bf4ced2 100644 --- a/map/framework.cpp +++ b/map/framework.cpp @@ -772,10 +772,13 @@ void Framework::StartInteractiveSearch(search::SearchParams const & params) m_lastSearch.m_callback = [this](Results const & results) { if (!results.IsEndMarker()) + { GetPlatform().RunOnGuiThread([this, results]() { - UpdateSearchResults(results); + if (IsISActive()) + FillSearchResultsMarks(results); }); + } }; } @@ -789,22 +792,6 @@ void Framework::UpdateUserViewportChanged() } } -void Framework::UpdateSearchResults(search::Results const & results) -{ - if (!results.IsEndMarker() && results.GetCount() > 0) - { - // Got here from search thread. Need to switch into GUI thread to modify search mark container. - // Do copy the results structure to pass into GUI thread. - GetPlatform().RunOnGuiThread(bind(&Framework::OnSearchResultsCallbackUI, this, results)); - } -} - -void Framework::OnSearchResultsCallbackUI(search::Results const & results) -{ - if (IsISActive()) - FillSearchResultsMarks(results); -} - void Framework::ClearAllCaches() { m_model.ClearCaches(); @@ -1025,14 +1012,13 @@ void Framework::LoadSearchResultMetadata(search::Result & res) const void Framework::ShowSearchResult(search::Result const & res) { + CancelInteractiveSearch(); + UserMarkControllerGuard guard(m_bmManager, UserMarkType::SEARCH_MARK); guard.m_controller.SetIsDrawable(false); guard.m_controller.Clear(); guard.m_controller.SetIsVisible(true); - m_lastSearch.Clear(); - m_fixedSearchResults = 0; - int scale; m2::PointD center; @@ -1258,6 +1244,7 @@ void Framework::CreateDrapeEngine(ref_ptr contextFactory, m_drapeEngine = make_unique_dp(move(p)); AddViewportListener([this](ScreenBase const & screen) { + UpdateUserViewportChanged(); m_currentModelView = screen; }); m_drapeEngine->SetTapEventInfoListener(bind(&Framework::OnTapEvent, this, _1, _2, _3, _4)); diff --git a/map/framework.hpp b/map/framework.hpp index 67f2371da3..63fbd32f8a 100644 --- a/map/framework.hpp +++ b/map/framework.hpp @@ -331,8 +331,6 @@ private: search::SearchParams m_lastSearch; uint8_t m_fixedSearchResults; - void OnSearchResultsCallback(search::Results const & results); - void OnSearchResultsCallbackUI(search::Results const & results); void FillSearchResultsMarks(search::Results const & results); void OnDownloadMapCallback(storage::TIndex const & countryIndex); @@ -355,9 +353,7 @@ public: void LoadSearchResultMetadata(search::Result & res) const; void ShowSearchResult(search::Result const & res); - size_t ShowAllSearchResults(search::Results const & results); - void UpdateSearchResults(search::Results const & results); void StartInteractiveSearch(search::SearchParams const & params); bool IsISActive() const { return !m_lastSearch.m_query.empty(); } diff --git a/map/user_mark_container.cpp b/map/user_mark_container.cpp index 43ef1c4486..98fb0475b9 100644 --- a/map/user_mark_container.cpp +++ b/map/user_mark_container.cpp @@ -219,7 +219,7 @@ void UserMarkContainer::Clear(size_t skipCount/* = 0*/) { SetDirty(); if (skipCount < m_userMarks.size()) - m_userMarks.erase(m_userMarks.begin() + skipCount, m_userMarks.end()); + m_userMarks.erase(m_userMarks.begin(), m_userMarks.end() - skipCount); } void UserMarkContainer::SetIsDrawable(bool isDrawable)