diff --git a/OsmAnd/src/net/osmand/plus/AsyncLoadingThread.java b/OsmAnd/src/net/osmand/plus/AsyncLoadingThread.java index 73f5f563e5..7d15bd75bd 100644 --- a/OsmAnd/src/net/osmand/plus/AsyncLoadingThread.java +++ b/OsmAnd/src/net/osmand/plus/AsyncLoadingThread.java @@ -6,6 +6,7 @@ import java.util.Stack; import net.osmand.Algoritms; import net.osmand.LogUtil; +import net.osmand.OsmAndFormatter; import net.osmand.ResultMatcher; import net.osmand.data.Amenity; import net.osmand.data.MapTileDownloader.DownloadRequest; @@ -237,12 +238,27 @@ public class AsyncLoadingThread extends Thread { private final List res; private final PoiFilter filter; private final int zoom; + private String filterByName; - public AmenityLoadRequest(List repos, int zoom, PoiFilter filter) { + public AmenityLoadRequest(List repos, int zoom, PoiFilter filter, String nameFilter) { super(); this.res = repos; this.zoom = zoom; this.filter = filter; + this.filterByName = nameFilter; + if(this.filterByName != null) { + this.filterByName = this.filterByName.toLowerCase().trim(); + } + } + + @Override + public boolean publish(Amenity object) { + if(filterByName == null || filterByName.length() == 0) { + return true; + } else { + String lower = OsmAndFormatter.getPoiStringWithoutType(object, OsmandApplication.getSettings().usingEnglishNames()).toLowerCase(); + return lower.indexOf(filterByName) != -1; + } } public Runnable prepareToRun() { diff --git a/OsmAnd/src/net/osmand/plus/OsmandApplication.java b/OsmAnd/src/net/osmand/plus/OsmandApplication.java index b57ac7e519..c47dfb2e08 100644 --- a/OsmAnd/src/net/osmand/plus/OsmandApplication.java +++ b/OsmAnd/src/net/osmand/plus/OsmandApplication.java @@ -129,6 +129,7 @@ public class OsmandApplication extends Application { } return osmandSettings; } + public PoiFiltersHelper getPoiFilters() { if (poiFilters == null) { diff --git a/OsmAnd/src/net/osmand/plus/ResourceManager.java b/OsmAnd/src/net/osmand/plus/ResourceManager.java index 713137dff5..e7c73a67ba 100644 --- a/OsmAnd/src/net/osmand/plus/ResourceManager.java +++ b/OsmAnd/src/net/osmand/plus/ResourceManager.java @@ -664,7 +664,7 @@ public class ResourceManager { } } if(!repos.isEmpty()){ - AmenityLoadRequest req = asyncLoadingThread.new AmenityLoadRequest(repos, zoom, filter); + AmenityLoadRequest req = asyncLoadingThread.new AmenityLoadRequest(repos, zoom, filter, filter.getFilterByName()); req.setBoundaries(topLatitude, leftLongitude, bottomLatitude, rightLongitude); asyncLoadingThread.requestToLoadAmenities(req); }