From eae2b1e7744645273f52e6d53b6747fc3520ee9c 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: Mon, 26 Feb 2018 19:35:06 +0300 Subject: [PATCH] [android] Added resetting filter controller when search query is cleared --- .../src/com/mapswithme/maps/MwmActivity.java | 24 +++++++++++++++++-- .../FloatingSearchToolbarController.java | 24 +++++++++++++++---- partners_api/booking_api.cpp | 2 +- 3 files changed, 42 insertions(+), 8 deletions(-) diff --git a/android/src/com/mapswithme/maps/MwmActivity.java b/android/src/com/mapswithme/maps/MwmActivity.java index 50c98cf973..004fa35f72 100644 --- a/android/src/com/mapswithme/maps/MwmActivity.java +++ b/android/src/com/mapswithme/maps/MwmActivity.java @@ -128,7 +128,8 @@ public class MwmActivity extends BaseMwmFragmentActivity RoutingPlanInplaceController.RoutingPlanListener, RoutingBottomMenuListener, BookmarkManager.BookmarksLoadingListener, - DiscoveryFragment.DiscoveryListener + DiscoveryFragment.DiscoveryListener, + FloatingSearchToolbarController.SearchToolbarListener { public static final String EXTRA_TASK = "map_task"; public static final String EXTRA_LAUNCH_BY_DEEP_LINK = "launch_by_deep_link"; @@ -522,7 +523,7 @@ public class MwmActivity extends BaseMwmFragmentActivity Statistics.INSTANCE.trackConnectionState(); - mSearchController = new FloatingSearchToolbarController(this); + mSearchController = new FloatingSearchToolbarController(this, this); mSearchController.setVisibilityListener(this); SearchEngine.INSTANCE.addListener(this); @@ -2360,6 +2361,25 @@ public class MwmActivity extends BaseMwmFragmentActivity R.string.load_kmz_failed); } + @Override + public void onSearchClearClick() + { + if (mFilterController != null) + mFilterController.resetFilter(); + } + + @Override + public void onSearchUpClick(@Nullable String query) + { + showSearch(query); + } + + @Override + public void onSearchQueryClick(@Nullable String query) + { + showSearch(query); + } + public static class ShowAuthorizationTask implements MapTask { @Override diff --git a/android/src/com/mapswithme/maps/search/FloatingSearchToolbarController.java b/android/src/com/mapswithme/maps/search/FloatingSearchToolbarController.java index f45d9f10b4..1f96d1449d 100644 --- a/android/src/com/mapswithme/maps/search/FloatingSearchToolbarController.java +++ b/android/src/com/mapswithme/maps/search/FloatingSearchToolbarController.java @@ -4,7 +4,6 @@ import android.app.Activity; import android.support.annotation.Nullable; import android.text.TextUtils; -import com.mapswithme.maps.MwmActivity; import com.mapswithme.maps.api.ParsedMwmRequest; import com.mapswithme.maps.widget.SearchToolbarController; import com.mapswithme.util.Animations; @@ -14,29 +13,34 @@ public class FloatingSearchToolbarController extends SearchToolbarController { @Nullable private VisibilityListener mVisibilityListener; + @Nullable + private SearchToolbarListener mListener; public interface VisibilityListener { void onSearchVisibilityChanged(boolean visible); } - public FloatingSearchToolbarController(Activity activity) + public FloatingSearchToolbarController(Activity activity, @Nullable SearchToolbarListener listener) { super(activity.getWindow().getDecorView(), activity); + mListener = listener; } @Override public void onUpClick() { - ((MwmActivity) mActivity).showSearch(getQuery()); + if (mListener != null) + mListener.onSearchUpClick(getQuery()); cancelSearchApiAndHide(true); } @Override - protected void onQueryClick(String query) + protected void onQueryClick(@Nullable String query) { super.onQueryClick(query); - ((MwmActivity) mActivity).showSearch(getQuery()); + if (mListener != null) + mListener.onSearchQueryClick(getQuery()); hide(); } @@ -44,6 +48,8 @@ public class FloatingSearchToolbarController extends SearchToolbarController protected void onClearClick() { super.onClearClick(); + if (mListener != null) + mListener.onSearchClearClick(); cancelSearchApiAndHide(false); } @@ -116,4 +122,12 @@ public class FloatingSearchToolbarController extends SearchToolbarController { mVisibilityListener = visibilityListener; } + + + public interface SearchToolbarListener + { + void onSearchUpClick(@Nullable String query); + void onSearchQueryClick(@Nullable String query); + void onSearchClearClick(); + } } diff --git a/partners_api/booking_api.cpp b/partners_api/booking_api.cpp index 1acd668792..fe209b6877 100644 --- a/partners_api/booking_api.cpp +++ b/partners_api/booking_api.cpp @@ -432,7 +432,7 @@ void Api::GetHotelInfo(string const & hotelId, string const & lang, } catch (my::Json::Exception const & e) { - LOG(LERROR, (e.Msg())); + LOG(LERROR, ("Failed to parse json:", result, e.what())); ClearHotelInfo(info); }