Fix poi additional filters for standalone category
This commit is contained in:
parent
7b12ccae2c
commit
177cd4eb6c
2 changed files with 33 additions and 17 deletions
|
@ -532,7 +532,11 @@ public class PoiUIFilter implements SearchPoiTypeFilter, Comparable<PoiUIFilter>
|
||||||
poiAdditionals.put(add.getKeyName().replace('_', ':').replace(' ', ':'), add);
|
poiAdditionals.put(add.getKeyName().replace('_', ':').replace(' ', ':'), add);
|
||||||
poiAdditionals.put(add.getTranslation().replace(' ', ':').toLowerCase(), add);
|
poiAdditionals.put(add.getTranslation().replace(' ', ':').toLowerCase(), add);
|
||||||
}
|
}
|
||||||
if (pt instanceof PoiFilter && !(pt instanceof PoiCategory)) {
|
if (pt instanceof PoiCategory) {
|
||||||
|
for (PoiFilter pf : ((PoiCategory) pt).getPoiFilters()) {
|
||||||
|
fillPoiAdditionals(pf);
|
||||||
|
}
|
||||||
|
} else if (pt instanceof PoiFilter) {
|
||||||
for (PoiType ps : ((PoiFilter) pt).getPoiTypes()) {
|
for (PoiType ps : ((PoiFilter) pt).getPoiTypes()) {
|
||||||
fillPoiAdditionals(ps);
|
fillPoiAdditionals(ps);
|
||||||
}
|
}
|
||||||
|
|
|
@ -432,16 +432,16 @@ public class QuickSearchPoiFilterFragment extends DialogFragment {
|
||||||
if (!excludedPoiAdditionalCategories.contains("opening_hours")) {
|
if (!excludedPoiAdditionalCategories.contains("opening_hours")) {
|
||||||
String keyNameOpen = app.getString(R.string.shared_string_is_open).replace(' ', '_').toLowerCase();
|
String keyNameOpen = app.getString(R.string.shared_string_is_open).replace(' ', '_').toLowerCase();
|
||||||
String keyNameOpen24 = app.getString(R.string.shared_string_is_open_24_7).replace(' ', '_').toLowerCase();
|
String keyNameOpen24 = app.getString(R.string.shared_string_is_open_24_7).replace(' ', '_').toLowerCase();
|
||||||
index = filterByName.indexOf(keyNameOpen);
|
|
||||||
if (index != -1) {
|
|
||||||
selectedPoiAdditionals.add(keyNameOpen);
|
|
||||||
filterByName = filterByName.replaceAll(keyNameOpen, "");
|
|
||||||
}
|
|
||||||
index = filterByName.indexOf(keyNameOpen24);
|
index = filterByName.indexOf(keyNameOpen24);
|
||||||
if (index != -1) {
|
if (index != -1) {
|
||||||
selectedPoiAdditionals.add(keyNameOpen24);
|
selectedPoiAdditionals.add(keyNameOpen24);
|
||||||
filterByName = filterByName.replaceAll(keyNameOpen24, "");
|
filterByName = filterByName.replaceAll(keyNameOpen24, "");
|
||||||
}
|
}
|
||||||
|
index = filterByName.indexOf(keyNameOpen);
|
||||||
|
if (index != -1) {
|
||||||
|
selectedPoiAdditionals.add(keyNameOpen);
|
||||||
|
filterByName = filterByName.replaceAll(keyNameOpen, "");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if (poiAdditionals != null) {
|
if (poiAdditionals != null) {
|
||||||
Map<String, List<PoiType>> additionalsMap = new TreeMap<>(String.CASE_INSENSITIVE_ORDER);
|
Map<String, List<PoiType>> additionalsMap = new TreeMap<>(String.CASE_INSENSITIVE_ORDER);
|
||||||
|
@ -472,25 +472,37 @@ 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()) {
|
||||||
if (entry.getKey().getExcludedPoiAdditionalCategories() != null) {
|
boolean needTopLevelExclude = false;
|
||||||
excludedPoiAdditionalCategories.addAll(entry.getKey().getExcludedPoiAdditionalCategories());
|
Set<String> excluded = new LinkedHashSet<>();
|
||||||
}
|
|
||||||
if (entry.getValue() != null) {
|
if (entry.getValue() != null) {
|
||||||
for (String keyName : entry.getValue()) {
|
for (String keyName : entry.getValue()) {
|
||||||
PoiType poiType = poiTypes.getPoiTypeByKey(keyName);
|
PoiType poiType = poiTypes.getPoiTypeByKey(keyName);
|
||||||
if (poiType != null) {
|
if (poiType != null) {
|
||||||
collectExcludedPoiAdditionalCategories(poiType, excludedPoiAdditionalCategories);
|
collectExcludedPoiAdditionalCategories(poiType, excluded);
|
||||||
|
if (!poiType.isReference()) {
|
||||||
|
needTopLevelExclude = true;
|
||||||
PoiFilter poiFilter = poiType.getFilter();
|
PoiFilter poiFilter = poiType.getFilter();
|
||||||
if (poiFilter != null) {
|
if (poiFilter != null) {
|
||||||
collectExcludedPoiAdditionalCategories(poiFilter, excludedPoiAdditionalCategories);
|
collectExcludedPoiAdditionalCategories(poiFilter, excluded);
|
||||||
}
|
}
|
||||||
PoiCategory poiCategory = poiType.getCategory();
|
PoiCategory poiCategory = poiType.getCategory();
|
||||||
if (poiCategory != null) {
|
if (poiCategory != null) {
|
||||||
collectExcludedPoiAdditionalCategories(poiCategory, excludedPoiAdditionalCategories);
|
collectExcludedPoiAdditionalCategories(poiCategory, excluded);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
needTopLevelExclude = true;
|
||||||
|
}
|
||||||
|
if (excludedPoiAdditionalCategories.size() == 0) {
|
||||||
|
excludedPoiAdditionalCategories.addAll(excluded);
|
||||||
|
} else {
|
||||||
|
excludedPoiAdditionalCategories.retainAll(excluded);
|
||||||
|
}
|
||||||
|
if (needTopLevelExclude && entry.getKey().getExcludedPoiAdditionalCategories() != null) {
|
||||||
|
excludedPoiAdditionalCategories.addAll(entry.getKey().getExcludedPoiAdditionalCategories());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return excludedPoiAdditionalCategories;
|
return excludedPoiAdditionalCategories;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue