From 2df673c297b5d0197a734a60db7e1c50d32f20ed Mon Sep 17 00:00:00 2001 From: Alexander Sytnyk Date: Wed, 25 Oct 2017 18:29:08 +0300 Subject: [PATCH] Do not show "Online Search" item if we already in online search --- .../plus/search/QuickSearchListAdapter.java | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/OsmAnd/src/net/osmand/plus/search/QuickSearchListAdapter.java b/OsmAnd/src/net/osmand/plus/search/QuickSearchListAdapter.java index 80705b8cc5..9bc16c38f2 100644 --- a/OsmAnd/src/net/osmand/plus/search/QuickSearchListAdapter.java +++ b/OsmAnd/src/net/osmand/plus/search/QuickSearchListAdapter.java @@ -29,6 +29,7 @@ import net.osmand.plus.search.listitems.QuickSearchListItem; import net.osmand.plus.search.listitems.QuickSearchListItemType; import net.osmand.plus.search.listitems.QuickSearchMoreListItem; import net.osmand.plus.search.listitems.QuickSearchSelectAllListItem; +import net.osmand.search.core.ObjectType; import net.osmand.search.core.SearchPhrase; import net.osmand.util.Algorithms; import net.osmand.util.OpeningHoursParser; @@ -235,7 +236,7 @@ public class QuickSearchListAdapter extends ArrayAdapter { view.findViewById(R.id.empty_search).setVisibility(View.GONE); view.findViewById(R.id.more_divider).setVisibility(View.GONE); } - if (OsmandPlugin.getEnabledPlugin(OsmandRasterMapsPlugin.class) != null) { + if (!alreadyInOnlineSearch() && OsmandPlugin.getEnabledPlugin(OsmandRasterMapsPlugin.class) != null) { view.findViewById(R.id.online_search_row).setVisibility(View.VISIBLE); view.findViewById(R.id.increase_radius_row).setOnClickListener(new View.OnClickListener() { @Override @@ -430,6 +431,18 @@ public class QuickSearchListAdapter extends ArrayAdapter { return view; } + private boolean alreadyInOnlineSearch() { + ObjectType[] types = app.getSearchUICore().getCore().getSearchSettings().getSearchTypes(); + if (types != null) { + for (ObjectType type : types) { + if (type == ObjectType.ONLINE_SEARCH) { + return true; + } + } + } + return false; + } + public void toggleCheckbox(int position, CheckBox ch) { QuickSearchListItemType type = getItem(position).getType(); if (type == QuickSearchListItemType.SELECT_ALL) {