Merge pull request #5158 from osmandapp/SearchCityWithoutStreets

Search city without streets
This commit is contained in:
Alexander Sytnyk 2018-03-23 14:57:45 +02:00 committed by GitHub
commit ad0d367153
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -33,6 +33,7 @@ import net.osmand.search.core.ObjectType;
import net.osmand.search.core.SearchResult;
import net.osmand.util.Algorithms;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
@ -97,7 +98,22 @@ public abstract class QuickSearchListFragment extends OsmAndListFragment {
showResult(sr);
} else {
dialogFragment.completeQueryWithObject(item.getSearchResult());
if ((sr.objectType == ObjectType.CITY || sr.objectType == ObjectType.VILLAGE)
&& sr.file != null && sr.object instanceof City) {
City c = (City) sr.object;
if (c.getStreets().isEmpty()) {
try {
sr.file.preloadStreets(c, null);
if (c.getStreets().isEmpty()) {
showResult(sr);
return;
}
} catch (IOException e) {
e.printStackTrace();
}
}
}
dialogFragment.completeQueryWithObject(sr);
}
}
}
@ -198,6 +214,7 @@ public abstract class QuickSearchListFragment extends OsmAndListFragment {
FavouritePoint fav = (FavouritePoint) object;
pointDescription = fav.getPointDescription();
break;
case VILLAGE:
case CITY:
String cityName = searchResult.localeName;
String typeNameCity = QuickSearchListItem.getTypeName(app, searchResult);