Do not show "Online Search" item if we already in online search

This commit is contained in:
Alexander Sytnyk 2017-10-25 18:29:08 +03:00
parent 7d7d9409ef
commit 2df673c297

View file

@ -29,6 +29,7 @@ import net.osmand.plus.search.listitems.QuickSearchListItem;
import net.osmand.plus.search.listitems.QuickSearchListItemType; import net.osmand.plus.search.listitems.QuickSearchListItemType;
import net.osmand.plus.search.listitems.QuickSearchMoreListItem; import net.osmand.plus.search.listitems.QuickSearchMoreListItem;
import net.osmand.plus.search.listitems.QuickSearchSelectAllListItem; import net.osmand.plus.search.listitems.QuickSearchSelectAllListItem;
import net.osmand.search.core.ObjectType;
import net.osmand.search.core.SearchPhrase; import net.osmand.search.core.SearchPhrase;
import net.osmand.util.Algorithms; import net.osmand.util.Algorithms;
import net.osmand.util.OpeningHoursParser; import net.osmand.util.OpeningHoursParser;
@ -235,7 +236,7 @@ public class QuickSearchListAdapter extends ArrayAdapter<QuickSearchListItem> {
view.findViewById(R.id.empty_search).setVisibility(View.GONE); view.findViewById(R.id.empty_search).setVisibility(View.GONE);
view.findViewById(R.id.more_divider).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.online_search_row).setVisibility(View.VISIBLE);
view.findViewById(R.id.increase_radius_row).setOnClickListener(new View.OnClickListener() { view.findViewById(R.id.increase_radius_row).setOnClickListener(new View.OnClickListener() {
@Override @Override
@ -430,6 +431,18 @@ public class QuickSearchListAdapter extends ArrayAdapter<QuickSearchListItem> {
return view; 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) { public void toggleCheckbox(int position, CheckBox ch) {
QuickSearchListItemType type = getItem(position).getType(); QuickSearchListItemType type = getItem(position).getType();
if (type == QuickSearchListItemType.SELECT_ALL) { if (type == QuickSearchListItemType.SELECT_ALL) {