More elegant fix for #2657

This commit is contained in:
sonora 2016-06-14 14:23:30 +02:00
parent d8dc055f82
commit 0927e79974
3 changed files with 18 additions and 0 deletions

View file

@ -185,6 +185,14 @@ public class SearchPOIActivity extends OsmandListActivity implements OsmAndCompa
return true;
}
@Override
protected void onDestroy() {
// Issue 2657
super.onDestroy();
if (!(currentSearchTask == null || currentSearchTask.getStatus() == Status.FINISHED)) {
currentSearchTask.cancel(true);
}
}
public Toolbar getClearToolbar(boolean visible) {
final Toolbar tb = (Toolbar) findViewById(R.id.poiSplitbar);

View file

@ -215,6 +215,9 @@ public class PoiUIFilter implements SearchPoiTypeFilter, Comparable<PoiUIFilter>
if (amenityList.size() == 0 && isAutomaticallyIncreaseSearch()) {
int step = 5;
while (amenityList.size() == 0 && step-- > 0 && isSearchFurtherAvailable()) {
if (matcher != null && matcher.isCancelled()) {
break;
}
amenityList = searchFurther(lat, lon, matcher);
}
}

View file

@ -757,6 +757,10 @@ public class ResourceManager {
try {
if (!filter.isEmpty()) {
for (AmenityIndexRepository index : amenityRepositories.values()) {
if (matcher != null && matcher.isCancelled()) {
searchAmenitiesInProgress = false;
break;
}
if (index.checkContains(topLatitude, leftLongitude, bottomLatitude, rightLongitude)) {
List<Amenity> r = index.searchAmenities(MapUtils.get31TileNumberY(topLatitude),
MapUtils.get31TileNumberX(leftLongitude), MapUtils.get31TileNumberY(bottomLatitude),
@ -832,6 +836,9 @@ public class ResourceManager {
List<Amenity> amenities = new ArrayList<Amenity>();
List<AmenityIndexRepositoryBinary> list = new ArrayList<AmenityIndexRepositoryBinary>();
for (AmenityIndexRepository index : amenityRepositories.values()) {
if (matcher != null && matcher.isCancelled()) {
break;
}
if (index instanceof AmenityIndexRepositoryBinary) {
if (index.checkContains(topLatitude, leftLongitude, bottomLatitude, rightLongitude)) {
if(index.checkContains(lat, lon)){