#2657 basic fix
This commit is contained in:
parent
60315668d4
commit
cf897d68ca
3 changed files with 29 additions and 11 deletions
|
@ -118,6 +118,7 @@ public class SearchPOIActivity extends OsmandListActivity implements OsmAndCompa
|
|||
private static int RESULT_REQUEST_CODE = 54;
|
||||
|
||||
private CharSequence tChange;
|
||||
public static boolean stopSearching = false;
|
||||
|
||||
@Override
|
||||
public boolean onCreateOptionsMenu(Menu omenu) {
|
||||
|
@ -185,6 +186,14 @@ public class SearchPOIActivity extends OsmandListActivity implements OsmAndCompa
|
|||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onDestroy() {
|
||||
super.onDestroy();
|
||||
if (!(currentSearchTask == null || currentSearchTask.getStatus() == Status.FINISHED)) {
|
||||
stopSearching = true;
|
||||
}
|
||||
}
|
||||
|
||||
public Toolbar getClearToolbar(boolean visible) {
|
||||
final Toolbar tb = (Toolbar) findViewById(R.id.poiSplitbar);
|
||||
tb.setTitle(null);
|
||||
|
@ -464,7 +473,7 @@ public class SearchPOIActivity extends OsmandListActivity implements OsmAndCompa
|
|||
}
|
||||
|
||||
private synchronized void runNewSearchQuery(net.osmand.Location location, int requestType) {
|
||||
if (currentSearchTask == null || currentSearchTask.getStatus() == Status.FINISHED ) {
|
||||
if (currentSearchTask == null || currentSearchTask.getStatus() == Status.FINISHED) {
|
||||
currentSearchTask = new SearchAmenityTask(location, requestType);
|
||||
currentSearchTask.execute();
|
||||
}
|
||||
|
@ -607,7 +616,6 @@ public class SearchPOIActivity extends OsmandListActivity implements OsmAndCompa
|
|||
public SearchAmenityTask(net.osmand.Location location, int requestType) {
|
||||
this.searchLocation = location;
|
||||
this.requestType = requestType;
|
||||
|
||||
}
|
||||
|
||||
net.osmand.Location getSearchedLocation() {
|
||||
|
@ -639,28 +647,28 @@ public class SearchPOIActivity extends OsmandListActivity implements OsmAndCompa
|
|||
|
||||
@Override
|
||||
protected void onPostExecute(List<Amenity> result) {
|
||||
setSupportProgressBarIndeterminateVisibility(false);
|
||||
currentSearchTask = null;
|
||||
updateButtonState(false);
|
||||
if (isNameSearch()) {
|
||||
if (isNominatimFilter() && !Algorithms.isEmpty(((NominatimPoiFilter) filter).getLastError())) {
|
||||
Toast.makeText(SearchPOIActivity.this, ((NominatimPoiFilter) filter).getLastError(),
|
||||
Toast.LENGTH_LONG).show();
|
||||
}
|
||||
amenityAdapter.setNewModel(result);
|
||||
if(showOnMapItem != null) {
|
||||
showOnMapItem.setEnabled(amenityAdapter.getCount() > 0);
|
||||
}
|
||||
} else {
|
||||
amenityAdapter.setNewModel(result);
|
||||
}
|
||||
// Issue #2667 (1)
|
||||
if (tChange != null) {
|
||||
changeFilter(tChange);
|
||||
tChange = null;
|
||||
}
|
||||
amenityAdapter.setNewModel(result);
|
||||
amenityAdapter.notifyDataSetChanged();
|
||||
lastSearchedLocation = searchLocation;
|
||||
setSupportProgressBarIndeterminateVisibility(false);
|
||||
currentSearchTask = null;
|
||||
stopSearching = false;
|
||||
//Toast.makeText(SearchPOIActivity.this, "onPostExecute has run", Toast.LENGTH_SHORT).show();
|
||||
updateButtonState(false);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -30,6 +30,7 @@ import net.osmand.osm.PoiType;
|
|||
import net.osmand.plus.OsmAndFormatter;
|
||||
import net.osmand.plus.OsmandApplication;
|
||||
import net.osmand.plus.R;
|
||||
import net.osmand.plus.activities.search.SearchPOIActivity;
|
||||
import net.osmand.util.Algorithms;
|
||||
import net.osmand.util.MapUtils;
|
||||
import net.osmand.util.OpeningHoursParser;
|
||||
|
@ -212,7 +213,7 @@ public class PoiUIFilter implements SearchPoiTypeFilter, Comparable<PoiUIFilter>
|
|||
amenityList.remove(amenityList.size() - 1);
|
||||
}
|
||||
}
|
||||
if (amenityList.size() == 0 && isAutomaticallyIncreaseSearch()) {
|
||||
if (amenityList.size() == 0 && isAutomaticallyIncreaseSearch() && !SearchPOIActivity.stopSearching) {
|
||||
int step = 5;
|
||||
while (amenityList.size() == 0 && step-- > 0 && isSearchFurtherAvailable()) {
|
||||
amenityList = searchFurther(lat, lon, matcher);
|
||||
|
|
|
@ -45,6 +45,7 @@ import net.osmand.plus.resources.AsyncLoadingThread.TileLoadDownloadRequest;
|
|||
import net.osmand.plus.resources.AsyncLoadingThread.TransportLoadRequest;
|
||||
import net.osmand.plus.srtmplugin.SRTMPlugin;
|
||||
import net.osmand.plus.views.OsmandMapLayer.DrawSettings;
|
||||
import net.osmand.plus.activities.search.SearchPOIActivity;
|
||||
import net.osmand.util.Algorithms;
|
||||
import net.osmand.util.MapUtils;
|
||||
|
||||
|
@ -757,6 +758,10 @@ public class ResourceManager {
|
|||
try {
|
||||
if (!filter.isEmpty()) {
|
||||
for (AmenityIndexRepository index : amenityRepositories.values()) {
|
||||
if (SearchPOIActivity.stopSearching) {
|
||||
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 +837,9 @@ public class ResourceManager {
|
|||
List<Amenity> amenities = new ArrayList<Amenity>();
|
||||
List<AmenityIndexRepositoryBinary> list = new ArrayList<AmenityIndexRepositoryBinary>();
|
||||
for (AmenityIndexRepository index : amenityRepositories.values()) {
|
||||
if (SearchPOIActivity.stopSearching) {
|
||||
break;
|
||||
}
|
||||
if (index instanceof AmenityIndexRepositoryBinary) {
|
||||
if (index.checkContains(topLatitude, leftLongitude, bottomLatitude, rightLongitude)) {
|
||||
if(index.checkContains(lat, lon)){
|
||||
|
@ -839,7 +847,6 @@ public class ResourceManager {
|
|||
} else {
|
||||
list.add((AmenityIndexRepositoryBinary) index);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -855,12 +862,14 @@ public class ResourceManager {
|
|||
if (matcher != null && matcher.isCancelled()) {
|
||||
break;
|
||||
}
|
||||
if (SearchPOIActivity.stopSearching) {
|
||||
break;
|
||||
}
|
||||
List<Amenity> result = index.searchAmenitiesByName(MapUtils.get31TileNumberX(lon), MapUtils.get31TileNumberY(lat),
|
||||
left, top, right, bottom,
|
||||
searchQuery, matcher);
|
||||
amenities.addAll(result);
|
||||
}
|
||||
|
||||
return amenities;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue