From b042a6e27b7c56fcb20ffe31bf6470e927ccedc5 Mon Sep 17 00:00:00 2001 From: Roman Inflianskas Date: Fri, 13 May 2016 19:34:41 +0300 Subject: [PATCH] Show all villages if no cities are present in region --- .../search/SearchByNameAbstractActivity.java | 2 +- .../activities/search/SearchCityByNameActivity.java | 12 +++++++++++- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/OsmAnd/src/net/osmand/plus/activities/search/SearchByNameAbstractActivity.java b/OsmAnd/src/net/osmand/plus/activities/search/SearchByNameAbstractActivity.java index 92e0844c1e..9c1a629720 100644 --- a/OsmAnd/src/net/osmand/plus/activities/search/SearchByNameAbstractActivity.java +++ b/OsmAnd/src/net/osmand/plus/activities/search/SearchByNameAbstractActivity.java @@ -296,7 +296,7 @@ public abstract class SearchByNameAbstractActivity extends OsmandListActivity protected void finishInitializing(List list){ Comparator cmp = createComparator(); getListAdapter().sort(cmp); - if(list != null){ + if (list != null) { Collections.sort(list,cmp); initialListToFilter = list; } diff --git a/OsmAnd/src/net/osmand/plus/activities/search/SearchCityByNameActivity.java b/OsmAnd/src/net/osmand/plus/activities/search/SearchCityByNameActivity.java index 37ebb68a4c..60b37901ab 100644 --- a/OsmAnd/src/net/osmand/plus/activities/search/SearchCityByNameActivity.java +++ b/OsmAnd/src/net/osmand/plus/activities/search/SearchCityByNameActivity.java @@ -34,6 +34,16 @@ public class SearchCityByNameActivity extends SearchByNameAbstractActivity private Button searchVillages; private OsmandSettings osmandSettings; + @Override + protected void finishInitializing(List list) { + // Show villages if cities are not present in this region + if (list != null && list.isEmpty()) { + searchVillagesMode = 0; + searchVillages.setVisibility(View.GONE); + } + super.finishInitializing(list); + } + @Override protected void reset() { //This is really only a "clear input text field", hence do not reset settings here @@ -141,7 +151,7 @@ public class SearchCityByNameActivity extends SearchByNameAbstractActivity private void redefineSearchVillagesMode(int queryLen) { if (searchVillagesMode == 1) { searchVillagesMode = 0; - } else if (searchVillagesMode == 0 && queryLen <= 3) { + } else if (searchVillagesMode == 0 && queryLen <= 3 && !initialListToFilter.isEmpty()) { searchVillagesMode = -1; uiHandler.post(new Runnable() { @Override