From c0ab369316ca6e37d224150373647a6df8277925 Mon Sep 17 00:00:00 2001 From: Victor Shcherb Date: Sun, 8 May 2016 23:22:48 +0200 Subject: [PATCH] Fix #2495 --- .../osmand/plus/poi/SearchByNameFilter.java | 44 ++++++++++--------- 1 file changed, 24 insertions(+), 20 deletions(-) diff --git a/OsmAnd/src/net/osmand/plus/poi/SearchByNameFilter.java b/OsmAnd/src/net/osmand/plus/poi/SearchByNameFilter.java index 3559f6093c..ec9d80546d 100644 --- a/OsmAnd/src/net/osmand/plus/poi/SearchByNameFilter.java +++ b/OsmAnd/src/net/osmand/plus/poi/SearchByNameFilter.java @@ -10,6 +10,7 @@ import net.osmand.data.Amenity; import net.osmand.osm.PoiCategory; import net.osmand.plus.OsmandApplication; import net.osmand.plus.R; +import net.osmand.util.Algorithms; import net.osmand.util.MapUtils; public class SearchByNameFilter extends PoiUIFilter { @@ -33,27 +34,30 @@ public class SearchByNameFilter extends PoiUIFilter { double bottomLatitude, double leftLongitude, double rightLongitude, final ResultMatcher matcher) { currentSearchResult = new ArrayList(); final int limit = distanceInd == 0 ? 500 : -1; - List result = app.getResourceManager().searchAmenitiesByName(getFilterByName(), - topLatitude, leftLongitude, bottomLatitude, rightLongitude, lat, lon, new ResultMatcher() { - boolean elimit = false; - @Override - public boolean publish(Amenity object) { - if (limit != -1 && currentSearchResult.size() > limit) { - elimit = true; - } - if (matcher.publish(object)) { - currentSearchResult.add(object); - return true; - } - return false; - } + if (!Algorithms.isBlank(getFilterByName())) { + List result = app.getResourceManager().searchAmenitiesByName(getFilterByName(), topLatitude, + leftLongitude, bottomLatitude, rightLongitude, lat, lon, new ResultMatcher() { + boolean elimit = false; - @Override - public boolean isCancelled() { - return matcher.isCancelled() || elimit; - } - }); - MapUtils.sortListOfMapObject(result, lat, lon); + @Override + public boolean publish(Amenity object) { + if (limit != -1 && currentSearchResult.size() > limit) { + elimit = true; + } + if (matcher.publish(object)) { + currentSearchResult.add(object); + return true; + } + return false; + } + + @Override + public boolean isCancelled() { + return matcher.isCancelled() || elimit; + } + }); + MapUtils.sortListOfMapObject(result, lat, lon); + } currentSearchResult = result; return currentSearchResult; }