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(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);
|
||||
|
||||
|
|
|
@ -93,6 +93,14 @@ public class RegionAddressRepositoryBinary implements RegionAddressRepository {
|
|||
fillWithSuggestedStreetsInCities(citiesToLook, name, streetsToFill);
|
||||
List<City> villages = file.getVillages(region);
|
||||
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) {
|
||||
log.error("Disk operation failed" , e);
|
||||
}
|
||||
|
|
|
@ -191,10 +191,17 @@ public abstract class SearchByNameAbstractActivity<T> extends ListActivity {
|
|||
|
||||
|
||||
class NamesAdapter extends ArrayAdapter<T> {
|
||||
private final List<T> list;
|
||||
|
||||
NamesAdapter(List<T> 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) {
|
||||
View row;
|
||||
if (convertView != null) {
|
||||
|
|
|
@ -38,15 +38,11 @@ public class SearchStreetByNameActivity extends SearchByNameAbstractActivity<Str
|
|||
public List<Street> getObjects(String filter) {
|
||||
NamesAdapter list = (NamesAdapter)getListAdapter();
|
||||
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;
|
||||
List<Street> result = new ArrayList<Street>();
|
||||
if (incremental) {
|
||||
List<Street> streets = new ArrayList<Street>();
|
||||
for (int i = 0; i < list.getCount(); i++ ) {
|
||||
streets.add((Street) list.getItem(i));
|
||||
}
|
||||
region.fillWithSuggestedStreets(filter,result,streets,countrySearch);
|
||||
region.fillWithSuggestedStreets(filter,result,list.getList(),countrySearch);
|
||||
} else {
|
||||
if (!countrySearch) {
|
||||
region.fillWithSuggestedStreets(postcode == null ? city : postcode, filter, result);
|
||||
|
|
Loading…
Reference in a new issue