Merge pull request #5167 from osmandapp/SearchCityWithoutStreets
Search city without streets
This commit is contained in:
commit
11c62326b7
1 changed files with 35 additions and 10 deletions
|
@ -10,6 +10,8 @@ import android.widget.AdapterView;
|
||||||
import android.widget.ArrayAdapter;
|
import android.widget.ArrayAdapter;
|
||||||
import android.widget.ListView;
|
import android.widget.ListView;
|
||||||
|
|
||||||
|
import net.osmand.ResultMatcher;
|
||||||
|
import net.osmand.binary.BinaryMapIndexReader;
|
||||||
import net.osmand.data.Amenity;
|
import net.osmand.data.Amenity;
|
||||||
import net.osmand.data.City;
|
import net.osmand.data.City;
|
||||||
import net.osmand.data.FavouritePoint;
|
import net.osmand.data.FavouritePoint;
|
||||||
|
@ -101,16 +103,9 @@ public abstract class QuickSearchListFragment extends OsmAndListFragment {
|
||||||
if ((sr.objectType == ObjectType.CITY || sr.objectType == ObjectType.VILLAGE)
|
if ((sr.objectType == ObjectType.CITY || sr.objectType == ObjectType.VILLAGE)
|
||||||
&& sr.file != null && sr.object instanceof City) {
|
&& sr.file != null && sr.object instanceof City) {
|
||||||
City c = (City) sr.object;
|
City c = (City) sr.object;
|
||||||
if (c.getStreets().isEmpty()) {
|
if (isCityEmpty(c, sr)) {
|
||||||
try {
|
showResult(sr);
|
||||||
sr.file.preloadStreets(c, null);
|
return;
|
||||||
if (c.getStreets().isEmpty()) {
|
|
||||||
showResult(sr);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
} catch (IOException e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
dialogFragment.completeQueryWithObject(sr);
|
dialogFragment.completeQueryWithObject(sr);
|
||||||
|
@ -120,6 +115,36 @@ public abstract class QuickSearchListFragment extends OsmAndListFragment {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public boolean isCityEmpty(City c, SearchResult sr) {
|
||||||
|
final boolean isEmpty[] = new boolean[1];
|
||||||
|
isEmpty[0] = true;
|
||||||
|
if (c.getStreets().isEmpty()) {
|
||||||
|
ResultMatcher<Street> resultMatcher = new ResultMatcher<Street>() {
|
||||||
|
boolean isCancelled = false;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean publish(Street object) {
|
||||||
|
isCancelled = true;
|
||||||
|
isEmpty[0] = false;
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean isCancelled() {
|
||||||
|
return isCancelled;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
try {
|
||||||
|
sr.file.preloadStreets(c, BinaryMapIndexReader.buildAddressRequest(resultMatcher));
|
||||||
|
} catch (IOException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
isEmpty[0] = false;
|
||||||
|
}
|
||||||
|
return isEmpty[0];
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onActivityCreated(Bundle savedInstanceState) {
|
public void onActivityCreated(Bundle savedInstanceState) {
|
||||||
super.onActivityCreated(savedInstanceState);
|
super.onActivityCreated(savedInstanceState);
|
||||||
|
|
Loading…
Reference in a new issue