diff --git a/OsmAnd/AndroidManifest.xml b/OsmAnd/AndroidManifest.xml index 88cea58a05..ed269d5df8 100644 --- a/OsmAnd/AndroidManifest.xml +++ b/OsmAnd/AndroidManifest.xml @@ -73,7 +73,7 @@ + android:screenOrientation="unspecified" android:launchMode="singleTask" android:windowSoftInputMode="adjustResize"> diff --git a/OsmAnd/src/net/osmand/plus/activities/search/SearchPOIActivity.java b/OsmAnd/src/net/osmand/plus/activities/search/SearchPOIActivity.java index 0011b2e664..d4fd1935e6 100644 --- a/OsmAnd/src/net/osmand/plus/activities/search/SearchPOIActivity.java +++ b/OsmAnd/src/net/osmand/plus/activities/search/SearchPOIActivity.java @@ -118,7 +118,6 @@ 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) { @@ -186,14 +185,6 @@ public class SearchPOIActivity extends OsmandListActivity implements OsmAndCompa return true; } - @Override - protected void onDestroy() { - // Issue 2657 - super.onDestroy(); - if (!(currentSearchTask == null || currentSearchTask.getStatus() == Status.FINISHED)) { - stopSearching = true; - } - } public Toolbar getClearToolbar(boolean visible) { final Toolbar tb = (Toolbar) findViewById(R.id.poiSplitbar); @@ -210,7 +201,7 @@ public class SearchPOIActivity extends OsmandListActivity implements OsmAndCompa .show(); return true; } - if ((isNameSearch() && !Algorithms.objectEquals(filter.getFilterByName(), query)) || stopSearching) { + if ((isNameSearch() && !Algorithms.objectEquals(filter.getFilterByName(), query)) ) { filter.clearPreviousZoom(); filter.setFilterByName(query); runNewSearchQuery(location, NEW_SEARCH_INIT); @@ -474,7 +465,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(); } @@ -617,6 +608,7 @@ 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() { @@ -648,28 +640,28 @@ public class SearchPOIActivity extends OsmandListActivity implements OsmAndCompa @Override protected void onPostExecute(List 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); } - amenityAdapter.setNewModel(result); - amenityAdapter.notifyDataSetChanged(); - lastSearchedLocation = searchLocation; - setSupportProgressBarIndeterminateVisibility(false); - stopSearching = false; - currentSearchTask = null; - //Toast.makeText(SearchPOIActivity.this, "onPostExecute has run", Toast.LENGTH_SHORT).show(); // Issue #2667 (1) if (tChange != null) { changeFilter(tChange); tChange = null; } - updateButtonState(false); + amenityAdapter.notifyDataSetChanged(); + lastSearchedLocation = searchLocation; } @Override diff --git a/OsmAnd/src/net/osmand/plus/poi/PoiUIFilter.java b/OsmAnd/src/net/osmand/plus/poi/PoiUIFilter.java index 805136603e..00e49b789c 100644 --- a/OsmAnd/src/net/osmand/plus/poi/PoiUIFilter.java +++ b/OsmAnd/src/net/osmand/plus/poi/PoiUIFilter.java @@ -30,7 +30,6 @@ 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; diff --git a/OsmAnd/src/net/osmand/plus/resources/ResourceManager.java b/OsmAnd/src/net/osmand/plus/resources/ResourceManager.java index ae3be71bce..87bb661591 100644 --- a/OsmAnd/src/net/osmand/plus/resources/ResourceManager.java +++ b/OsmAnd/src/net/osmand/plus/resources/ResourceManager.java @@ -45,7 +45,6 @@ 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; @@ -758,10 +757,6 @@ 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 r = index.searchAmenities(MapUtils.get31TileNumberY(topLatitude), MapUtils.get31TileNumberX(leftLongitude), MapUtils.get31TileNumberY(bottomLatitude), @@ -837,9 +832,6 @@ public class ResourceManager { List amenities = new ArrayList(); List list = new ArrayList(); 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)){ @@ -847,6 +839,7 @@ public class ResourceManager { } else { list.add((AmenityIndexRepositoryBinary) index); } + } } } @@ -863,14 +856,12 @@ public class ResourceManager { if (matcher != null && matcher.isCancelled()) { break; } - if (SearchPOIActivity.stopSearching) { - break; - } List result = index.searchAmenitiesByName(MapUtils.get31TileNumberX(lon), MapUtils.get31TileNumberY(lat), left, top, right, bottom, searchQuery, matcher); amenities.addAll(result); } + return amenities; }