From 0939e31a98c84024b419da64988b5fea8298fabb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=90=D0=BB=D0=B5=D0=BA=D1=81=D0=B0=D0=BD=D0=B4=D1=80=20?= =?UTF-8?q?=D0=97=D0=B0=D1=86=D0=B5=D0=BF=D0=B8=D0=BD?= Date: Fri, 12 Jan 2018 14:07:18 +0300 Subject: [PATCH] [android] Removed akward/redundant showing search results from the local cache --- .../jni/com/mapswithme/maps/SearchEngine.cpp | 12 ++--------- .../src/com/mapswithme/maps/MwmActivity.java | 2 +- .../mapswithme/maps/search/SearchEngine.java | 21 +++++++++---------- .../maps/search/SearchFragment.java | 2 +- 4 files changed, 14 insertions(+), 23 deletions(-) diff --git a/android/jni/com/mapswithme/maps/SearchEngine.cpp b/android/jni/com/mapswithme/maps/SearchEngine.cpp index 692b0920ab..921d599b07 100644 --- a/android/jni/com/mapswithme/maps/SearchEngine.cpp +++ b/android/jni/com/mapswithme/maps/SearchEngine.cpp @@ -305,10 +305,8 @@ private: bool m_initialized = false; } g_bookingAvailabilityParamsBuilder; -// TODO yunitsky -// Do not cache search results here, after new search will be implemented. -// Currently we cannot serialize FeatureID of search result properly. -// Cache is needed to show results on the map after click in the list of results. +// This cache is needed only for showing a specific result on the map after click on the list item. +// Don't use it with another intentions! Results g_results; // Timestamp of last search query. Results with older stamps are ignored. @@ -581,12 +579,6 @@ extern "C" g_framework->NativeFramework()->ShowSearchResult(g_results[index]); } - JNIEXPORT void JNICALL - Java_com_mapswithme_maps_search_SearchEngine_nativeShowAllResults(JNIEnv * env, jclass clazz) - { - g_framework->NativeFramework()->ShowSearchResults(g_results); - } - JNIEXPORT void JNICALL Java_com_mapswithme_maps_search_SearchEngine_nativeCancelInteractiveSearch(JNIEnv * env, jclass clazz) { diff --git a/android/src/com/mapswithme/maps/MwmActivity.java b/android/src/com/mapswithme/maps/MwmActivity.java index 3d16ea195a..507d4c125d 100644 --- a/android/src/com/mapswithme/maps/MwmActivity.java +++ b/android/src/com/mapswithme/maps/MwmActivity.java @@ -593,7 +593,7 @@ public class MwmActivity extends BaseMwmFragmentActivity false /* isMapAndTable */, mFilterController != null ? mFilterController.getFilter() : null, mFilterController != null ? mFilterController.getBookingFilterParams() : null); - SearchEngine.showAllResults(mSearchController.getQuery()); + SearchEngine.setQuery(mSearchController.getQuery()); } private void initPositionChooser() diff --git a/android/src/com/mapswithme/maps/search/SearchEngine.java b/android/src/com/mapswithme/maps/search/SearchEngine.java index d7c6067032..b3499914f4 100644 --- a/android/src/com/mapswithme/maps/search/SearchEngine.java +++ b/android/src/com/mapswithme/maps/search/SearchEngine.java @@ -1,6 +1,7 @@ package com.mapswithme.maps.search; -import java.io.UnsupportedEncodingException; +import android.support.annotation.NonNull; +import android.support.annotation.Nullable; import com.mapswithme.maps.Framework; import com.mapswithme.maps.api.ParsedMwmRequest; @@ -9,8 +10,7 @@ import com.mapswithme.util.Language; import com.mapswithme.util.Listeners; import com.mapswithme.util.concurrency.UiThread; -import android.support.annotation.NonNull; -import android.support.annotation.Nullable; +import java.io.UnsupportedEncodingException; public enum SearchEngine implements NativeSearchListener, NativeMapSearchListener, @@ -19,6 +19,7 @@ public enum SearchEngine implements NativeSearchListener, INSTANCE; // Query, which results are shown on the map. + @Nullable private static String sSavedQuery; @Override @@ -145,6 +146,12 @@ public enum SearchEngine implements NativeSearchListener, } catch (UnsupportedEncodingException ignored) { } } + public static void setQuery(@Nullable String query) + { + sSavedQuery = query; + } + + @Nullable public static String getQuery() { return sSavedQuery; @@ -181,12 +188,6 @@ public enum SearchEngine implements NativeSearchListener, nativeShowResult(index); } - public static void showAllResults(String query) - { - sSavedQuery = query; - nativeShowAllResults(); - } - /** * @param bytes utf-8 formatted bytes of query. */ @@ -209,8 +210,6 @@ public enum SearchEngine implements NativeSearchListener, private static native void nativeShowResult(int index); - private static native void nativeShowAllResults(); - public static native void nativeCancelInteractiveSearch(); public static native void nativeCancelEverywhereSearch(); diff --git a/android/src/com/mapswithme/maps/search/SearchFragment.java b/android/src/com/mapswithme/maps/search/SearchFragment.java index 66726ffd1c..672d3439f3 100644 --- a/android/src/com/mapswithme/maps/search/SearchFragment.java +++ b/android/src/com/mapswithme/maps/search/SearchFragment.java @@ -591,7 +591,7 @@ public class SearchFragment extends BaseMwmFragment ? mInitialLocale : com.mapswithme.util.Language.getKeyboardLocale(), mLastQueryTimestamp, false /* isMapAndTable */, hotelsFilter, bookingFilterParams); - SearchEngine.showAllResults(query); + SearchEngine.setQuery(query); Utils.navigateToParent(getActivity()); Statistics.INSTANCE.trackEvent(Statistics.EventName.SEARCH_ON_MAP_CLICKED);