Forget to sync on ui thread,
forget to sort streets.
This commit is contained in:
parent
d5ca3f3961
commit
2d6f46e41e
4 changed files with 18 additions and 7 deletions
|
@ -70,7 +70,7 @@ public interface RegionAddressRepository {
|
||||||
public void fillWithSuggestedStreets(String name, List<Street> streetsToFill);
|
public void fillWithSuggestedStreets(String name, List<Street> streetsToFill);
|
||||||
|
|
||||||
public void fillWithSuggestedStreets(final String name,
|
public void fillWithSuggestedStreets(final String name,
|
||||||
List<Street> streetsToFill, Collection<Street> streets, boolean onlyStartCheck);
|
List<Street> streetsToFill, Collection<Street> sortedStreets, boolean onlyStartCheck);
|
||||||
|
|
||||||
public void fillWithSuggestedCities(String name, List<MapObject> citiesToFill, LatLon currentLocation);
|
public void fillWithSuggestedCities(String name, List<MapObject> citiesToFill, LatLon currentLocation);
|
||||||
|
|
||||||
|
|
|
@ -93,6 +93,14 @@ public class RegionAddressRepositoryBinary implements RegionAddressRepository {
|
||||||
fillWithSuggestedStreetsInCities(citiesToLook, name, streetsToFill);
|
fillWithSuggestedStreetsInCities(citiesToLook, name, streetsToFill);
|
||||||
List<City> villages = file.getVillages(region);
|
List<City> villages = file.getVillages(region);
|
||||||
fillWithSuggestedStreetsInCities(villages, name, streetsToFill);
|
fillWithSuggestedStreetsInCities(villages, name, streetsToFill);
|
||||||
|
Collections.sort(streetsToFill, new Comparator<Street>() {
|
||||||
|
@Override
|
||||||
|
public int compare(Street object1, Street object2) {
|
||||||
|
String name1 = object1.getName(useEnglishNames);
|
||||||
|
String name2 = object2.getName(useEnglishNames);
|
||||||
|
return collator.compare(name1,name2);
|
||||||
|
}
|
||||||
|
});
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
log.error("Disk operation failed" , e);
|
log.error("Disk operation failed" , e);
|
||||||
}
|
}
|
||||||
|
|
|
@ -191,10 +191,17 @@ public abstract class SearchByNameAbstractActivity<T> extends ListActivity {
|
||||||
|
|
||||||
|
|
||||||
class NamesAdapter extends ArrayAdapter<T> {
|
class NamesAdapter extends ArrayAdapter<T> {
|
||||||
|
private final List<T> list;
|
||||||
|
|
||||||
NamesAdapter(List<T> list) {
|
NamesAdapter(List<T> list) {
|
||||||
super(SearchByNameAbstractActivity.this, R.layout.searchbyname_list, list);
|
super(SearchByNameAbstractActivity.this, R.layout.searchbyname_list, list);
|
||||||
|
this.list = list;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public List<T> getList() {
|
||||||
|
return list;
|
||||||
|
}
|
||||||
|
|
||||||
public View getView(int position, View convertView, ViewGroup parent) {
|
public View getView(int position, View convertView, ViewGroup parent) {
|
||||||
View row;
|
View row;
|
||||||
if (convertView != null) {
|
if (convertView != null) {
|
||||||
|
|
|
@ -38,15 +38,11 @@ public class SearchStreetByNameActivity extends SearchByNameAbstractActivity<Str
|
||||||
public List<Street> getObjects(String filter) {
|
public List<Street> getObjects(String filter) {
|
||||||
NamesAdapter list = (NamesAdapter)getListAdapter();
|
NamesAdapter list = (NamesAdapter)getListAdapter();
|
||||||
boolean countrySearch = isCountrySearch();
|
boolean countrySearch = isCountrySearch();
|
||||||
boolean incremental = filter.startsWith(oldfilter) && oldfilter.length() > 0 && list.getCount() > 0;
|
boolean incremental = filter.startsWith(oldfilter) && oldfilter.length() > 0 && !list.getList().isEmpty();
|
||||||
this.oldfilter = filter;
|
this.oldfilter = filter;
|
||||||
List<Street> result = new ArrayList<Street>();
|
List<Street> result = new ArrayList<Street>();
|
||||||
if (incremental) {
|
if (incremental) {
|
||||||
List<Street> streets = new ArrayList<Street>();
|
region.fillWithSuggestedStreets(filter,result,list.getList(),countrySearch);
|
||||||
for (int i = 0; i < list.getCount(); i++ ) {
|
|
||||||
streets.add((Street) list.getItem(i));
|
|
||||||
}
|
|
||||||
region.fillWithSuggestedStreets(filter,result,streets,countrySearch);
|
|
||||||
} else {
|
} else {
|
||||||
if (!countrySearch) {
|
if (!countrySearch) {
|
||||||
region.fillWithSuggestedStreets(postcode == null ? city : postcode, filter, result);
|
region.fillWithSuggestedStreets(postcode == null ? city : postcode, filter, result);
|
||||||
|
|
Loading…
Reference in a new issue