This commit is contained in:
Alexey Kulish 2016-10-14 09:59:56 +03:00
parent e817a70ff4
commit cfbd2fc54c
3 changed files with 52 additions and 13 deletions

View file

@ -27,7 +27,16 @@ public class PoiCategory extends PoiFilter {
public List<PoiFilter> getPoiFilters() {
return poiFilters;
}
public PoiFilter getPoiFilterByName(String keyName) {
for (PoiFilter f : poiFilters) {
if (f.getKeyName().equals(keyName)) {
return f;
}
}
return null;
}
public String getDefaultTag() {
if(defaultTag == null) {
return keyName;

View file

@ -9,6 +9,7 @@ import net.osmand.data.QuadRect;
import net.osmand.data.TransportRoute;
import net.osmand.data.TransportStop;
import net.osmand.osm.PoiCategory;
import net.osmand.osm.PoiFilter;
import net.osmand.osm.PoiType;
import net.osmand.plus.OsmandApplication;
import net.osmand.plus.R;
@ -39,7 +40,19 @@ public class AmenityMenuController extends MenuController {
super(new AmenityMenuBuilder(app, amenity), pointDescription, mapActivity);
this.amenity = amenity;
if (amenity.getType().getKeyName().equals("transportation")) {
processTransportStop();
boolean showTransportStops = false;
PoiFilter f = amenity.getType().getPoiFilterByName("public_transport");
if (f != null) {
for (PoiType t : f.getPoiTypes()) {
if (t.getKeyName().equals(amenity.getSubType())) {
showTransportStops = true;
break;
}
}
}
if (showTransportStops) {
processTransportStop();
}
}
}
@ -139,7 +152,7 @@ public class AmenityMenuController extends MenuController {
};
if (r.type == null) {
builder.addPlainMenuItem(R.drawable.ic_action_polygom_dark, r.getDescription(getMapActivity().getMyApplication(), true),
false, false, listener );
false, false, listener);
} else {
builder.addPlainMenuItem(r.type.getResourceId(), r.getDescription(getMapActivity().getMyApplication(), true),
false, false, listener);
@ -202,7 +215,7 @@ public class AmenityMenuController extends MenuController {
TransportStopController.TransportStopType type = TransportStopController.TransportStopType.findType(rs.getType());
TransportStopRoute r = new TransportStopRoute();
r.type = type;
r.desc = rs.getRef() + " " + (useEnglishNames ? rs.getEnName(true) : rs.getName());
r.desc = rs.getRef() + " " + (useEnglishNames ? rs.getEnName(true) : rs.getName());
r.route = rs;
r.stop = s;
r.distance = dist;

View file

@ -29,8 +29,10 @@ import android.widget.TextView;
import android.widget.Toast;
import net.osmand.AndroidUtils;
import net.osmand.osm.AbstractPoiType;
import net.osmand.osm.MapPoiTypes;
import net.osmand.osm.PoiCategory;
import net.osmand.osm.PoiFilter;
import net.osmand.osm.PoiType;
import net.osmand.plus.IconsCache;
import net.osmand.plus.OsmandApplication;
@ -464,19 +466,34 @@ public class QuickSearchPoiFilterFragment extends DialogFragment {
MapPoiTypes poiTypes = getMyApplication().getPoiTypes();
Set<String> excludedPoiAdditionalCategories = new LinkedHashSet<>();
for (Entry<PoiCategory, LinkedHashSet<String>> entry : filter.getAcceptedTypes().entrySet()) {
if (entry.getKey().getExcludedPoiAdditionalCategories() != null) {
excludedPoiAdditionalCategories.addAll(entry.getKey().getExcludedPoiAdditionalCategories());
for (PoiFilter f : entry.getKey().getPoiFilters()) {
for (PoiType t : f.getPoiTypes()) {
collectExcludedCategories(poiTypes, t, null, excludedPoiAdditionalCategories);
}
collectExcludedCategories(poiTypes, f, null, excludedPoiAdditionalCategories);
}
if (entry.getValue() != null) {
for (String keyName : entry.getValue()) {
List<String> categories = poiTypes.getPoiTypeByKey(keyName).getExcludedPoiAdditionalCategories();
if (categories != null) {
excludedPoiAdditionalCategories.addAll(categories);
}
for (PoiType t : entry.getKey().getPoiTypes()) {
collectExcludedCategories(poiTypes, t, null, excludedPoiAdditionalCategories);
}
collectExcludedCategories(poiTypes, entry.getKey(), entry.getValue(), excludedPoiAdditionalCategories);
}
return excludedPoiAdditionalCategories;
}
private void collectExcludedCategories(MapPoiTypes poiTypes,
AbstractPoiType type, LinkedHashSet<String> names,
Set<String> excludedPoiAdditionalCategories) {
if (type.getExcludedPoiAdditionalCategories() != null) {
excludedPoiAdditionalCategories.addAll(type.getExcludedPoiAdditionalCategories());
}
if (names != null) {
for (String keyName : names) {
List<String> categories = poiTypes.getPoiTypeByKey(keyName).getExcludedPoiAdditionalCategories();
if (categories != null) {
excludedPoiAdditionalCategories.addAll(categories);
}
}
}
return excludedPoiAdditionalCategories;
}
private List<PoiFilterListItem> getListItems() {