[android] Added resetting filter controller when search query is cleared

This commit is contained in:
Александр Зацепин 2018-02-26 19:35:06 +03:00 committed by Aleksandr Zatsepin
parent a01a6f9c48
commit eae2b1e774
3 changed files with 42 additions and 8 deletions

View file

@ -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

View file

@ -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();
}
}

View file

@ -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);
}