Fixed excluded categories and icons
This commit is contained in:
parent
c40bf1d713
commit
5c3f322ed3
3 changed files with 36 additions and 31 deletions
|
@ -321,7 +321,7 @@ public class MapPoiTypes {
|
||||||
}
|
}
|
||||||
lastCategory.addPoiType(tp);
|
lastCategory.addPoiType(tp);
|
||||||
} else if (name.equals("poi_reference")) {
|
} else if (name.equals("poi_reference")) {
|
||||||
PoiType tp = new PoiType(this, lastCategory, parser.getAttributeValue("", "name"));
|
PoiType tp = new PoiType(this, lastCategory, lastFilter, parser.getAttributeValue("", "name"));
|
||||||
referenceTypes.add(tp);
|
referenceTypes.add(tp);
|
||||||
tp.setReferenceType(tp);
|
tp.setReferenceType(tp);
|
||||||
if (lastFilter != null) {
|
if (lastFilter != null) {
|
||||||
|
@ -465,7 +465,7 @@ public class MapPoiTypes {
|
||||||
if (lang != null) {
|
if (lang != null) {
|
||||||
otag += ":" + lang;
|
otag += ":" + lang;
|
||||||
}
|
}
|
||||||
PoiType tp = new PoiType(this, lastCategory, oname);
|
PoiType tp = new PoiType(this, lastCategory, lastFilter, oname);
|
||||||
tp.setBaseLangType(langBaseType);
|
tp.setBaseLangType(langBaseType);
|
||||||
tp.setLang(lang);
|
tp.setLang(lang);
|
||||||
tp.setAdditional(lastType != null ? lastType :
|
tp.setAdditional(lastType != null ? lastType :
|
||||||
|
@ -499,7 +499,7 @@ public class MapPoiTypes {
|
||||||
if (lang != null) {
|
if (lang != null) {
|
||||||
oname += ":" + lang;
|
oname += ":" + lang;
|
||||||
}
|
}
|
||||||
PoiType tp = new PoiType(this, lastCategory, oname);
|
PoiType tp = new PoiType(this, lastCategory, lastFilter, oname);
|
||||||
String otag = parser.getAttributeValue("", "tag");
|
String otag = parser.getAttributeValue("", "tag");
|
||||||
if (lang != null) {
|
if (lang != null) {
|
||||||
otag += ":" + lang;
|
otag += ":" + lang;
|
||||||
|
|
|
@ -6,6 +6,7 @@ import java.util.Map;
|
||||||
public class PoiType extends AbstractPoiType {
|
public class PoiType extends AbstractPoiType {
|
||||||
|
|
||||||
private PoiCategory category;
|
private PoiCategory category;
|
||||||
|
private PoiFilter filter;
|
||||||
private AbstractPoiType parentType;
|
private AbstractPoiType parentType;
|
||||||
private PoiType referenceType;
|
private PoiType referenceType;
|
||||||
private String osmTag;
|
private String osmTag;
|
||||||
|
@ -22,11 +23,12 @@ public class PoiType extends AbstractPoiType {
|
||||||
private int order = 90;
|
private int order = 90;
|
||||||
|
|
||||||
|
|
||||||
public PoiType(MapPoiTypes poiTypes, PoiCategory category, String name) {
|
public PoiType(MapPoiTypes poiTypes, PoiCategory category, PoiFilter filter, String name) {
|
||||||
super(name, poiTypes);
|
super(name, poiTypes);
|
||||||
this.category = category;
|
this.category = category;
|
||||||
|
this.filter = filter;
|
||||||
}
|
}
|
||||||
|
|
||||||
public PoiType getReferenceType() {
|
public PoiType getReferenceType() {
|
||||||
return referenceType;
|
return referenceType;
|
||||||
}
|
}
|
||||||
|
@ -104,7 +106,11 @@ public class PoiType extends AbstractPoiType {
|
||||||
public PoiCategory getCategory() {
|
public PoiCategory getCategory() {
|
||||||
return category;
|
return category;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public PoiFilter getFilter() {
|
||||||
|
return filter;
|
||||||
|
}
|
||||||
|
|
||||||
public Map<PoiCategory, LinkedHashSet<String>> putTypes(Map<PoiCategory, LinkedHashSet<String>> acceptedTypes) {
|
public Map<PoiCategory, LinkedHashSet<String>> putTypes(Map<PoiCategory, LinkedHashSet<String>> acceptedTypes) {
|
||||||
if (isAdditional()) {
|
if (isAdditional()) {
|
||||||
return parentType.putTypes(acceptedTypes);
|
return parentType.putTypes(acceptedTypes);
|
||||||
|
|
|
@ -466,33 +466,34 @@ public class QuickSearchPoiFilterFragment extends DialogFragment {
|
||||||
MapPoiTypes poiTypes = getMyApplication().getPoiTypes();
|
MapPoiTypes poiTypes = getMyApplication().getPoiTypes();
|
||||||
Set<String> excludedPoiAdditionalCategories = new LinkedHashSet<>();
|
Set<String> excludedPoiAdditionalCategories = new LinkedHashSet<>();
|
||||||
for (Entry<PoiCategory, LinkedHashSet<String>> entry : filter.getAcceptedTypes().entrySet()) {
|
for (Entry<PoiCategory, LinkedHashSet<String>> entry : filter.getAcceptedTypes().entrySet()) {
|
||||||
for (PoiFilter f : entry.getKey().getPoiFilters()) {
|
if (entry.getKey().getExcludedPoiAdditionalCategories() != null) {
|
||||||
for (PoiType t : f.getPoiTypes()) {
|
excludedPoiAdditionalCategories.addAll(entry.getKey().getExcludedPoiAdditionalCategories());
|
||||||
collectExcludedCategories(poiTypes, t, null, excludedPoiAdditionalCategories);
|
}
|
||||||
|
if (entry.getValue() != null) {
|
||||||
|
for (String keyName : entry.getValue()) {
|
||||||
|
PoiType poiType = poiTypes.getPoiTypeByKey(keyName);
|
||||||
|
if (poiType != null) {
|
||||||
|
collectExcludedPoiAdditionalCategories(poiType, excludedPoiAdditionalCategories);
|
||||||
|
PoiFilter poiFilter = poiType.getFilter();
|
||||||
|
if (poiFilter != null) {
|
||||||
|
collectExcludedPoiAdditionalCategories(poiFilter, excludedPoiAdditionalCategories);
|
||||||
|
}
|
||||||
|
PoiCategory poiCategory = poiType.getCategory();
|
||||||
|
if (poiCategory != null) {
|
||||||
|
collectExcludedPoiAdditionalCategories(poiCategory, excludedPoiAdditionalCategories);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
collectExcludedCategories(poiTypes, f, null, excludedPoiAdditionalCategories);
|
|
||||||
}
|
}
|
||||||
for (PoiType t : entry.getKey().getPoiTypes()) {
|
|
||||||
collectExcludedCategories(poiTypes, t, null, excludedPoiAdditionalCategories);
|
|
||||||
}
|
|
||||||
collectExcludedCategories(poiTypes, entry.getKey(), entry.getValue(), excludedPoiAdditionalCategories);
|
|
||||||
}
|
}
|
||||||
return excludedPoiAdditionalCategories;
|
return excludedPoiAdditionalCategories;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void collectExcludedCategories(MapPoiTypes poiTypes,
|
private void collectExcludedPoiAdditionalCategories(AbstractPoiType abstractPoiType,
|
||||||
AbstractPoiType type, LinkedHashSet<String> names,
|
Set<String> excludedPoiAdditionalCategories) {
|
||||||
Set<String> excludedPoiAdditionalCategories) {
|
List<String> categories = abstractPoiType.getExcludedPoiAdditionalCategories();
|
||||||
if (type.getExcludedPoiAdditionalCategories() != null) {
|
if (categories != null) {
|
||||||
excludedPoiAdditionalCategories.addAll(type.getExcludedPoiAdditionalCategories());
|
excludedPoiAdditionalCategories.addAll(categories);
|
||||||
}
|
|
||||||
if (names != null) {
|
|
||||||
for (String keyName : names) {
|
|
||||||
List<String> categories = poiTypes.getPoiTypeByKey(keyName).getExcludedPoiAdditionalCategories();
|
|
||||||
if (categories != null) {
|
|
||||||
excludedPoiAdditionalCategories.addAll(categories);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -528,11 +529,9 @@ public class QuickSearchPoiFilterFragment extends DialogFragment {
|
||||||
items.add(new PoiFilterListItem(PoiFilterListItemType.DIVIDER, 0, null, -1, false, false, false, null, null));
|
items.add(new PoiFilterListItem(PoiFilterListItemType.DIVIDER, 0, null, -1, false, false, false, null, null));
|
||||||
|
|
||||||
String categoryIconStr = poiTypes.getPoiAdditionalCategoryIcon(category);
|
String categoryIconStr = poiTypes.getPoiAdditionalCategoryIcon(category);
|
||||||
int categoryIconId;
|
int categoryIconId = 0;
|
||||||
if (!Algorithms.isEmpty(categoryIconStr)) {
|
if (!Algorithms.isEmpty(categoryIconStr)) {
|
||||||
categoryIconId = getResources().getIdentifier(categoryIconStr, "drawable", app.getPackageName());
|
categoryIconId = RenderingIcons.getBigIconResourceId(categoryIconStr);
|
||||||
} else {
|
|
||||||
categoryIconId = RenderingIcons.getBigIconResourceId(category);
|
|
||||||
}
|
}
|
||||||
if (categoryIconId == 0) {
|
if (categoryIconId == 0) {
|
||||||
categoryIconId = R.drawable.ic_action_folder_stroke;
|
categoryIconId = R.drawable.ic_action_folder_stroke;
|
||||||
|
|
Loading…
Reference in a new issue