Formatting

This commit is contained in:
Roman Inflianskas 2016-07-05 19:20:58 +03:00
parent 75eb46b71e
commit b8dc11bad9

View file

@ -38,12 +38,12 @@ import android.content.Context;
import android.support.annotation.NonNull; import android.support.annotation.NonNull;
public class PoiUIFilter implements SearchPoiTypeFilter, Comparable<PoiUIFilter> { public class PoiUIFilter implements SearchPoiTypeFilter, Comparable<PoiUIFilter> {
public final static String STD_PREFIX = "std_"; //$NON-NLS-1$ public final static String STD_PREFIX = "std_"; //$NON-NLS-1$
public final static String USER_PREFIX = "user_"; //$NON-NLS-1$ public final static String USER_PREFIX = "user_"; //$NON-NLS-1$
public final static String CUSTOM_FILTER_ID = USER_PREFIX + "custom_id"; //$NON-NLS-1$ public final static String CUSTOM_FILTER_ID = USER_PREFIX + "custom_id"; //$NON-NLS-1$
public final static String BY_NAME_FILTER_ID = USER_PREFIX + "by_name"; //$NON-NLS-1$ public final static String BY_NAME_FILTER_ID = USER_PREFIX + "by_name"; //$NON-NLS-1$
private Map<PoiCategory, LinkedHashSet<String>> acceptedTypes = new LinkedHashMap<PoiCategory, private Map<PoiCategory, LinkedHashSet<String>> acceptedTypes = new LinkedHashMap<PoiCategory,
LinkedHashSet<String>>(); LinkedHashSet<String>>();
private Map<String, PoiType> poiAdditionals = new HashMap<String, PoiType>(); private Map<String, PoiType> poiAdditionals = new HashMap<String, PoiType>();
@ -52,15 +52,15 @@ public class PoiUIFilter implements SearchPoiTypeFilter, Comparable<PoiUIFilter>
protected String standardIconId = ""; protected String standardIconId = "";
protected String name; protected String name;
protected boolean isStandardFilter; protected boolean isStandardFilter;
protected final OsmandApplication app; protected final OsmandApplication app;
protected int distanceInd = 0; protected int distanceInd = 0;
// in kilometers // in kilometers
protected double[] distanceToSearchValues = new double[] {1, 2, 5, 10, 20, 50, 100, 200, 500}; protected double[] distanceToSearchValues = new double[]{1, 2, 5, 10, 20, 50, 100, 200, 500};
private final MapPoiTypes poiTypes; private final MapPoiTypes poiTypes;
protected String filterByName = null; protected String filterByName = null;
protected String savedFilterByName = null; protected String savedFilterByName = null;
protected List<Amenity> currentSearchResult = null; protected List<Amenity> currentSearchResult = null;
@ -71,21 +71,21 @@ public class PoiUIFilter implements SearchPoiTypeFilter, Comparable<PoiUIFilter>
isStandardFilter = true; isStandardFilter = true;
standardIconId = (type == null ? null : type.getKeyName()); standardIconId = (type == null ? null : type.getKeyName());
filterId = STD_PREFIX + standardIconId + idSuffix; filterId = STD_PREFIX + standardIconId + idSuffix;
poiTypes = application.getPoiTypes(); poiTypes = application.getPoiTypes();
name = type == null ? application.getString(R.string.poi_filter_closest_poi) : (type.getTranslation() + idSuffix); //$NON-NLS-1$ name = type == null ? application.getString(R.string.poi_filter_closest_poi) : (type.getTranslation() + idSuffix); //$NON-NLS-1$
if (type == null) { if (type == null) {
initSearchAll(); initSearchAll();
updatePoiAdditionals(); updatePoiAdditionals();
} else { } else {
if(type.isAdditional()) { if (type.isAdditional()) {
setSavedFilterByName(type.getKeyName().replace('_', ':')); setSavedFilterByName(type.getKeyName().replace('_', ':'));
} }
updateTypesToAccept(type); updateTypesToAccept(type);
} }
} }
// search by name standard // search by name standard
protected PoiUIFilter(OsmandApplication application) { protected PoiUIFilter(OsmandApplication application) {
this.app = application; this.app = application;
@ -95,8 +95,8 @@ public class PoiUIFilter implements SearchPoiTypeFilter, Comparable<PoiUIFilter>
} }
// constructor for user defined filters // constructor for user defined filters
public PoiUIFilter(String name, String filterId, public PoiUIFilter(String name, String filterId,
Map<PoiCategory, LinkedHashSet<String>> acceptedTypes, OsmandApplication app){ Map<PoiCategory, LinkedHashSet<String>> acceptedTypes, OsmandApplication app) {
this.app = app; this.app = app;
isStandardFilter = false; isStandardFilter = false;
poiTypes = app.getPoiTypes(); poiTypes = app.getPoiTypes();
@ -123,38 +123,38 @@ public class PoiUIFilter implements SearchPoiTypeFilter, Comparable<PoiUIFilter>
public String getFilterByName() { public String getFilterByName() {
return filterByName; return filterByName;
} }
public void setFilterByName(String filterByName) { public void setFilterByName(String filterByName) {
this.filterByName = filterByName; this.filterByName = filterByName;
updateFilterResults(); updateFilterResults();
} }
public void updateFilterResults() { public void updateFilterResults() {
List<Amenity> prev = currentSearchResult; List<Amenity> prev = currentSearchResult;
if (prev != null) { if (prev != null) {
AmenityNameFilter nameFilter = getNameFilter(filterByName); AmenityNameFilter nameFilter = getNameFilter(filterByName);
List<Amenity> newResults = new ArrayList<Amenity>(); List<Amenity> newResults = new ArrayList<Amenity>();
for(Amenity a : prev) { for (Amenity a : prev) {
if(nameFilter.accept(a)) { if (nameFilter.accept(a)) {
newResults.add(a); newResults.add(a);
} }
} }
currentSearchResult = newResults; currentSearchResult = newResults;
} }
} }
public void setSavedFilterByName(String filterByName) { public void setSavedFilterByName(String filterByName) {
this.filterByName = filterByName; this.filterByName = filterByName;
this.savedFilterByName = filterByName; this.savedFilterByName = filterByName;
} }
public String getSavedFilterByName() { public String getSavedFilterByName() {
return savedFilterByName; return savedFilterByName;
} }
public List<Amenity> searchAgain(double lat, double lon) { public List<Amenity> searchAgain(double lat, double lon) {
List<Amenity> amenityList ; List<Amenity> amenityList;
if (currentSearchResult != null) { if (currentSearchResult != null) {
amenityList = currentSearchResult; amenityList = currentSearchResult;
} else { } else {
@ -163,47 +163,47 @@ public class PoiUIFilter implements SearchPoiTypeFilter, Comparable<PoiUIFilter>
MapUtils.sortListOfMapObject(amenityList, lat, lon); MapUtils.sortListOfMapObject(amenityList, lat, lon);
return amenityList; return amenityList;
} }
public List<Amenity> searchFurther(double latitude, double longitude, ResultMatcher<Amenity> matcher){
public List<Amenity> searchFurther(double latitude, double longitude, ResultMatcher<Amenity> matcher) {
if (distanceInd < distanceToSearchValues.length - 1) { if (distanceInd < distanceToSearchValues.length - 1) {
distanceInd ++; distanceInd++;
} }
List<Amenity> amenityList = searchAmenities( latitude, longitude, matcher); List<Amenity> amenityList = searchAmenities(latitude, longitude, matcher);
MapUtils.sortListOfMapObject(amenityList, latitude, longitude); MapUtils.sortListOfMapObject(amenityList, latitude, longitude);
return amenityList; return amenityList;
} }
private void initSearchAll(){ private void initSearchAll() {
for(PoiCategory t : poiTypes.getCategories(false)){ for (PoiCategory t : poiTypes.getCategories(false)) {
acceptedTypes.put(t, null); acceptedTypes.put(t, null);
} }
distanceToSearchValues = new double[] {0.5, 1, 2, 5, 10, 20, 50, 100}; distanceToSearchValues = new double[]{0.5, 1, 2, 5, 10, 20, 50, 100};
} }
public boolean isSearchFurtherAvailable(){ public boolean isSearchFurtherAvailable() {
return distanceInd < distanceToSearchValues.length - 1; return distanceInd < distanceToSearchValues.length - 1;
} }
public String getSearchArea(boolean next) { public String getSearchArea(boolean next) {
int distInd = distanceInd; int distInd = distanceInd;
if (next && (distanceInd < distanceToSearchValues.length - 1)) { if (next && (distanceInd < distanceToSearchValues.length - 1)) {
//This is workaround for the SearchAmenityTask.onPreExecute() case //This is workaround for the SearchAmenityTask.onPreExecute() case
distInd = distanceInd + 1; distInd = distanceInd + 1;
} }
double val = distanceToSearchValues[distInd]; double val = distanceToSearchValues[distInd];
if(val >= 1){ if (val >= 1) {
return " < " + OsmAndFormatter.getFormattedDistance(((int)val * 1000), app); //$NON-NLS-1$//$NON-NLS-2$ return " < " + OsmAndFormatter.getFormattedDistance(((int) val * 1000), app); //$NON-NLS-1$//$NON-NLS-2$
} else { } else {
return " < " + OsmAndFormatter.getFormattedDistance(500, app); //$NON-NLS-1$ return " < " + OsmAndFormatter.getFormattedDistance(500, app); //$NON-NLS-1$
} }
} }
public void clearPreviousZoom(){ public void clearPreviousZoom() {
distanceInd = 0; distanceInd = 0;
} }
public List<Amenity> initializeNewSearch(double lat, double lon, int firstTimeLimit, ResultMatcher<Amenity> matcher){ public List<Amenity> initializeNewSearch(double lat, double lon, int firstTimeLimit, ResultMatcher<Amenity> matcher) {
clearPreviousZoom(); clearPreviousZoom();
List<Amenity> amenityList = searchAmenities(lat, lon, matcher); List<Amenity> amenityList = searchAmenities(lat, lon, matcher);
MapUtils.sortListOfMapObject(amenityList, lat, lon); MapUtils.sortListOfMapObject(amenityList, lat, lon);
@ -221,24 +221,24 @@ public class PoiUIFilter implements SearchPoiTypeFilter, Comparable<PoiUIFilter>
amenityList = searchFurther(lat, lon, matcher); amenityList = searchFurther(lat, lon, matcher);
} }
} }
return amenityList; return amenityList;
} }
public boolean isAutomaticallyIncreaseSearch() { public boolean isAutomaticallyIncreaseSearch() {
return true; return true;
} }
private List<Amenity> searchAmenities(double lat, double lon, ResultMatcher<Amenity> matcher) { private List<Amenity> searchAmenities(double lat, double lon, ResultMatcher<Amenity> matcher) {
double baseDistY = MapUtils.getDistance(lat, lon, lat - 1, lon); double baseDistY = MapUtils.getDistance(lat, lon, lat - 1, lon);
double baseDistX = MapUtils.getDistance(lat, lon, lat, lon - 1); double baseDistX = MapUtils.getDistance(lat, lon, lat, lon - 1);
double distance = distanceToSearchValues[distanceInd] * 1000; double distance = distanceToSearchValues[distanceInd] * 1000;
double topLatitude = Math.min(lat + (distance/ baseDistY ), 84.); double topLatitude = Math.min(lat + (distance / baseDistY), 84.);
double bottomLatitude = Math.max(lat - (distance/ baseDistY ), -84.); double bottomLatitude = Math.max(lat - (distance / baseDistY), -84.);
double leftLongitude = Math.max(lon - (distance / baseDistX), -180); double leftLongitude = Math.max(lon - (distance / baseDistX), -180);
double rightLongitude = Math.min(lon + (distance/ baseDistX), 180); double rightLongitude = Math.min(lon + (distance / baseDistX), 180);
return searchAmenitiesInternal(lat, lon, topLatitude, bottomLatitude, leftLongitude, rightLongitude, matcher); return searchAmenitiesInternal(lat, lon, topLatitude, bottomLatitude, leftLongitude, rightLongitude, matcher);
} }
public List<Amenity> searchAmenities(double top, double left, double bottom, double right, int zoom, public List<Amenity> searchAmenities(double top, double left, double bottom, double right, int zoom,
ResultMatcher<Amenity> matcher) { ResultMatcher<Amenity> matcher) {
List<Amenity> results = new ArrayList<Amenity>(); List<Amenity> results = new ArrayList<Amenity>();
@ -259,21 +259,21 @@ public class PoiUIFilter implements SearchPoiTypeFilter, Comparable<PoiUIFilter>
results.addAll(amenities); results.addAll(amenities);
return results; return results;
} }
public List<Amenity> searchAmenitiesOnThePath(List<Location> locs, int poiSearchDeviationRadius) { public List<Amenity> searchAmenitiesOnThePath(List<Location> locs, int poiSearchDeviationRadius) {
return app.getResourceManager().searchAmenitiesOnThePath(locs, poiSearchDeviationRadius, this, wrapResultMatcher(null)); return app.getResourceManager().searchAmenitiesOnThePath(locs, poiSearchDeviationRadius, this, wrapResultMatcher(null));
} }
protected List<Amenity> searchAmenitiesInternal(double lat, double lon, double topLatitude, protected List<Amenity> searchAmenitiesInternal(double lat, double lon, double topLatitude,
double bottomLatitude, double leftLongitude, double rightLongitude, final ResultMatcher<Amenity> matcher) { double bottomLatitude, double leftLongitude, double rightLongitude, final ResultMatcher<Amenity> matcher) {
return app.getResourceManager().searchAmenities(this, return app.getResourceManager().searchAmenities(this,
topLatitude, leftLongitude, bottomLatitude, rightLongitude, -1, wrapResultMatcher(matcher)); topLatitude, leftLongitude, bottomLatitude, rightLongitude, -1, wrapResultMatcher(matcher));
} }
public AmenityNameFilter getNameFilter(String filter) { public AmenityNameFilter getNameFilter(String filter) {
if (Algorithms.isEmpty(filter)) { if (Algorithms.isEmpty(filter)) {
return new AmenityNameFilter() { return new AmenityNameFilter() {
@Override @Override
public boolean accept(Amenity a) { public boolean accept(Amenity a) {
return true; return true;
@ -284,16 +284,16 @@ public class PoiUIFilter implements SearchPoiTypeFilter, Comparable<PoiUIFilter>
String[] items = filter.split(" "); String[] items = filter.split(" ");
boolean allTime = false; boolean allTime = false;
boolean open = false; boolean open = false;
Map<PoiType, String> poiAdditionalsFilter = null; Map<PoiType, String> poiAdditionalsFilter = null;
for(String s : items) { for (String s : items) {
s = s.trim(); s = s.trim();
if(!Algorithms.isEmpty(s)){ if (!Algorithms.isEmpty(s)) {
if(getNameToken24H().equalsIgnoreCase(s)){ if (getNameToken24H().equalsIgnoreCase(s)) {
allTime = true; allTime = true;
} else if(getNameTokenOpen().equalsIgnoreCase(s)){ } else if (getNameTokenOpen().equalsIgnoreCase(s)) {
open = true; open = true;
} else if(poiAdditionals.containsKey(s.toLowerCase())) { } else if (poiAdditionals.containsKey(s.toLowerCase())) {
if(poiAdditionalsFilter == null) { if (poiAdditionalsFilter == null) {
poiAdditionalsFilter = new LinkedHashMap<PoiType, String>(); poiAdditionalsFilter = new LinkedHashMap<PoiType, String>();
} }
poiAdditionalsFilter.put(poiAdditionals.get(s.toLowerCase()), null); poiAdditionalsFilter.put(poiAdditionals.get(s.toLowerCase()), null);
@ -311,7 +311,7 @@ public class PoiUIFilter implements SearchPoiTypeFilter, Comparable<PoiUIFilter>
nmFilter.length() > 0 ? nmFilter.length() > 0 ?
new CollatorStringMatcher(nmFilter.toString().trim(), StringMatcherMode.CHECK_CONTAINS) : null; new CollatorStringMatcher(nmFilter.toString().trim(), StringMatcherMode.CHECK_CONTAINS) : null;
return new AmenityNameFilter() { return new AmenityNameFilter() {
@Override @Override
public boolean accept(Amenity a) { public boolean accept(Amenity a) {
if (sm != null) { if (sm != null) {
@ -320,14 +320,14 @@ public class PoiUIFilter implements SearchPoiTypeFilter, Comparable<PoiUIFilter>
return false; return false;
} }
} }
if(poiAdditionals != null) { if (poiAdditionals != null) {
Iterator<Entry<PoiType, String>> it = poiAdditionals.entrySet().iterator(); Iterator<Entry<PoiType, String>> it = poiAdditionals.entrySet().iterator();
while(it.hasNext()) { while (it.hasNext()) {
Entry<PoiType, String> e = it.next(); Entry<PoiType, String> e = it.next();
String inf = a.getAdditionalInfo(e.getKey().getKeyName()); String inf = a.getAdditionalInfo(e.getKey().getKeyName());
if(inf == null) { if (inf == null) {
return false; return false;
} else if(e.getValue() != null && !e.getValue().equalsIgnoreCase(inf)) { } else if (e.getValue() != null && !e.getValue().equalsIgnoreCase(inf)) {
return false; return false;
} }
} }
@ -354,11 +354,11 @@ public class PoiUIFilter implements SearchPoiTypeFilter, Comparable<PoiUIFilter>
} }
}; };
} }
public String getNameToken24H() { public String getNameToken24H() {
return app.getString(R.string.shared_string_is_open_24_7).replace(' ', '_').toLowerCase(); return app.getString(R.string.shared_string_is_open_24_7).replace(' ', '_').toLowerCase();
} }
public String getNameTokenOpen() { public String getNameTokenOpen() {
return app.getString(R.string.shared_string_is_open).replace(' ', '_').toLowerCase(); return app.getString(R.string.shared_string_is_open).replace(' ', '_').toLowerCase();
} }
@ -366,7 +366,7 @@ public class PoiUIFilter implements SearchPoiTypeFilter, Comparable<PoiUIFilter>
private ResultMatcher<Amenity> wrapResultMatcher(final ResultMatcher<Amenity> matcher) { private ResultMatcher<Amenity> wrapResultMatcher(final ResultMatcher<Amenity> matcher) {
final AmenityNameFilter nm = getNameFilter(filterByName); final AmenityNameFilter nm = getNameFilter(filterByName);
return new ResultMatcher<Amenity>() { return new ResultMatcher<Amenity>() {
@Override @Override
public boolean publish(Amenity a) { public boolean publish(Amenity a) {
if (nm.accept(a)) { if (nm.accept(a)) {
@ -383,11 +383,11 @@ public class PoiUIFilter implements SearchPoiTypeFilter, Comparable<PoiUIFilter>
} }
}; };
} }
public String getName(){ public String getName() {
return name; return name;
} }
public String getGeneratedName(int chars) { public String getGeneratedName(int chars) {
if (!filterId.equals(CUSTOM_FILTER_ID) || if (!filterId.equals(CUSTOM_FILTER_ID) ||
areAllTypesAccepted() || acceptedTypes.isEmpty()) { areAllTypesAccepted() || acceptedTypes.isEmpty()) {
@ -425,31 +425,31 @@ public class PoiUIFilter implements SearchPoiTypeFilter, Comparable<PoiUIFilter>
} }
return res.toString(); return res.toString();
} }
/** /**
* @param type * @param type
* @return null if all subtypes are accepted/ empty list if type is not accepted at all * @return null if all subtypes are accepted/ empty list if type is not accepted at all
*/ */
public Set<String> getAcceptedSubtypes(PoiCategory type){ public Set<String> getAcceptedSubtypes(PoiCategory type) {
if(!acceptedTypes.containsKey(type)){ if (!acceptedTypes.containsKey(type)) {
return Collections.emptySet(); return Collections.emptySet();
} }
return acceptedTypes.get(type); return acceptedTypes.get(type);
} }
public boolean isTypeAccepted(PoiCategory t){ public boolean isTypeAccepted(PoiCategory t) {
return acceptedTypes.containsKey(t); return acceptedTypes.containsKey(t);
} }
public void clearFilter() { public void clearFilter() {
acceptedTypes = new LinkedHashMap<PoiCategory, LinkedHashSet<String>>(); acceptedTypes = new LinkedHashMap<PoiCategory, LinkedHashSet<String>>();
poiAdditionals.clear(); poiAdditionals.clear();
} }
public boolean areAllTypesAccepted(){ public boolean areAllTypesAccepted() {
if(poiTypes.getCategories(false).size() == acceptedTypes.size()){ if (poiTypes.getCategories(false).size() == acceptedTypes.size()) {
for(PoiCategory a : acceptedTypes.keySet()){ for (PoiCategory a : acceptedTypes.keySet()) {
if(acceptedTypes.get(a) != null){ if (acceptedTypes.get(a) != null) {
return false; return false;
} }
} }
@ -466,19 +466,19 @@ public class PoiUIFilter implements SearchPoiTypeFilter, Comparable<PoiUIFilter>
fillPoiAdditionals(pt); fillPoiAdditionals(pt);
} }
} }
private void fillPoiAdditionals(AbstractPoiType pt) { private void fillPoiAdditionals(AbstractPoiType pt) {
for (PoiType add : pt.getPoiAdditionals()) { for (PoiType add : pt.getPoiAdditionals()) {
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 PoiFilter && !(pt instanceof PoiCategory)) {
for(PoiType ps : ((PoiFilter) pt).getPoiTypes()) { for (PoiType ps : ((PoiFilter) pt).getPoiTypes()) {
fillPoiAdditionals(ps); fillPoiAdditionals(ps);
} }
} }
} }
private void updatePoiAdditionals() { private void updatePoiAdditionals() {
Iterator<Entry<PoiCategory, LinkedHashSet<String>>> e = acceptedTypes.entrySet().iterator(); Iterator<Entry<PoiCategory, LinkedHashSet<String>>> e = acceptedTypes.entrySet().iterator();
poiAdditionals.clear(); poiAdditionals.clear();
@ -527,15 +527,15 @@ public class PoiUIFilter implements SearchPoiTypeFilter, Comparable<PoiUIFilter>
combineWithPoiFilter(f); combineWithPoiFilter(f);
} }
public Map<PoiCategory, LinkedHashSet<String>> getAcceptedTypes(){ public Map<PoiCategory, LinkedHashSet<String>> getAcceptedTypes() {
return new LinkedHashMap<PoiCategory, LinkedHashSet<String>>(acceptedTypes); return new LinkedHashMap<PoiCategory, LinkedHashSet<String>>(acceptedTypes);
} }
public void selectSubTypesToAccept(PoiCategory t, LinkedHashSet<String> accept){ public void selectSubTypesToAccept(PoiCategory t, LinkedHashSet<String> accept) {
acceptedTypes.put(t, accept); acceptedTypes.put(t, accept);
fillPoiAdditionals(t); fillPoiAdditionals(t);
} }
public void setTypeToAccept(PoiCategory poiCategory, boolean b) { public void setTypeToAccept(PoiCategory poiCategory, boolean b) {
if (b) { if (b) {
acceptedTypes.put(poiCategory, null); acceptedTypes.put(poiCategory, null);
@ -544,16 +544,16 @@ public class PoiUIFilter implements SearchPoiTypeFilter, Comparable<PoiUIFilter>
} }
updatePoiAdditionals(); updatePoiAdditionals();
} }
public String getFilterId(){ public String getFilterId() {
return filterId; return filterId;
} }
public Map<String, PoiType> getPoiAdditionals() { public Map<String, PoiType> getPoiAdditionals() {
return poiAdditionals; return poiAdditionals;
} }
public String getIconId(){ public String getIconId() {
if (filterId.startsWith(STD_PREFIX)) { if (filterId.startsWith(STD_PREFIX)) {
return standardIconId; return standardIconId;
} else if (filterId.startsWith(USER_PREFIX)) { } else if (filterId.startsWith(USER_PREFIX)) {
@ -561,19 +561,19 @@ public class PoiUIFilter implements SearchPoiTypeFilter, Comparable<PoiUIFilter>
} }
return filterId; return filterId;
} }
public boolean isStandardFilter() { public boolean isStandardFilter() {
return isStandardFilter; return isStandardFilter;
} }
public void setStandardFilter(boolean isStandardFilter) { public void setStandardFilter(boolean isStandardFilter) {
this.isStandardFilter = isStandardFilter; this.isStandardFilter = isStandardFilter;
} }
public Context getApplication() { public Context getApplication() {
return app; return app;
} }
@Override @Override
public boolean accept(PoiCategory type, String subtype) { public boolean accept(PoiCategory type, String subtype) {
if (type == null) { if (type == null) {
@ -582,11 +582,11 @@ public class PoiUIFilter implements SearchPoiTypeFilter, Comparable<PoiUIFilter>
if (!poiTypes.isRegisteredType(type)) { if (!poiTypes.isRegisteredType(type)) {
type = poiTypes.getOtherPoiCategory(); type = poiTypes.getOtherPoiCategory();
} }
if (!acceptedTypes.containsKey(type)){ if (!acceptedTypes.containsKey(type)) {
return false; return false;
} }
LinkedHashSet<String> set = acceptedTypes.get(type); LinkedHashSet<String> set = acceptedTypes.get(type);
if (set == null){ if (set == null) {
return true; return true;
} }
return set.contains(subtype); return set.contains(subtype);
@ -603,13 +603,13 @@ public class PoiUIFilter implements SearchPoiTypeFilter, Comparable<PoiUIFilter>
if (another.filterId.equals(this.filterId)) { if (another.filterId.equals(this.filterId)) {
return 0; return 0;
} else { } else {
return this.name.compareTo(another.name); return this.name.compareTo(another.name);
} }
} }
public interface AmenityNameFilter { public interface AmenityNameFilter {
public boolean accept(Amenity a) ; public boolean accept(Amenity a);
} }
} }