Fix issue 754. Name filter
This commit is contained in:
parent
a261f9447c
commit
c7bb033d81
3 changed files with 19 additions and 2 deletions
|
@ -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<AmenityIndexRepository> res;
|
||||
private final PoiFilter filter;
|
||||
private final int zoom;
|
||||
private String filterByName;
|
||||
|
||||
public AmenityLoadRequest(List<AmenityIndexRepository> repos, int zoom, PoiFilter filter) {
|
||||
public AmenityLoadRequest(List<AmenityIndexRepository> 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() {
|
||||
|
|
|
@ -129,6 +129,7 @@ public class OsmandApplication extends Application {
|
|||
}
|
||||
return osmandSettings;
|
||||
}
|
||||
|
||||
|
||||
public PoiFiltersHelper getPoiFilters() {
|
||||
if (poiFilters == null) {
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue