diff --git a/OsmAnd/src/com/osmand/PoiFilter.java b/OsmAnd/src/com/osmand/PoiFilter.java index df20514ee5..24ddca4aae 100644 --- a/OsmAnd/src/com/osmand/PoiFilter.java +++ b/OsmAnd/src/com/osmand/PoiFilter.java @@ -26,7 +26,7 @@ public class PoiFilter { private final static int finalZoom = 6; private final static int initialZoom = 13; - private final static int maxCount = 200; + private final static int maxInitialCount = 200; private int zoom = initialZoom; @@ -85,12 +85,21 @@ public class PoiFilter { } } - public List initializeNewSearch(double lat, double lon, int firstTimeLimit){ - zoom = initialZoom; + public void clearPreviousZoom(){ + zoom = getInitialZoom(); + } + + private int getInitialZoom(){ + int zoom = initialZoom; if(areAllTypesAccepted()){ zoom += 1; } - List amenityList = ResourceManager.getResourceManager().searchAmenities(this, lat, lon, zoom, maxCount); + return zoom; + } + + public List initializeNewSearch(double lat, double lon, int firstTimeLimit){ + zoom = getInitialZoom(); + List amenityList = ResourceManager.getResourceManager().searchAmenities(this, lat, lon, zoom, maxInitialCount); MapUtils.sortListOfMapObject(amenityList, lat, lon); while (amenityList.size() > firstTimeLimit) { amenityList.remove(amenityList.size() - 1); @@ -100,7 +109,11 @@ public class PoiFilter { } public List searchAgain(double lat, double lon){ - List amenityList = ResourceManager.getResourceManager().searchAmenities(this, lat, lon, zoom, maxCount); + int limit = -1; + if(zoom == getInitialZoom()){ + limit = maxInitialCount; + } + List amenityList = ResourceManager.getResourceManager().searchAmenities(this, lat, lon, zoom, limit); MapUtils.sortListOfMapObject(amenityList, lat, lon); return amenityList; } diff --git a/OsmAnd/src/com/osmand/activities/DownloadIndexActivity.java b/OsmAnd/src/com/osmand/activities/DownloadIndexActivity.java index 05c9c2dd09..2c009b1387 100644 --- a/OsmAnd/src/com/osmand/activities/DownloadIndexActivity.java +++ b/OsmAnd/src/com/osmand/activities/DownloadIndexActivity.java @@ -108,11 +108,12 @@ public class DownloadIndexActivity extends ListActivity { final File fileToSave = resolveFileName(e.getKey(), regionName); if (fileToSave != null) { Builder builder = new AlertDialog.Builder(this); - if(!fileToSave.exists()){ + File toCheck = new File(fileToSave.getParent(), fileToSave.getName().substring(fileToSave.getName().length() - 4) +".odb"); //$NON-NLS-1$ + if(!toCheck.exists()){ builder.setMessage(MessageFormat.format(getString(R.string.download_question), regionName, e.getValue())); } else { MessageFormat format = new MessageFormat("{0,date,dd.MM.yyyy} : {1, number,##.#} MB", Locale.US); //$NON-NLS-1$ - String description = format.format(new Object[]{new Date(fileToSave.lastModified()), ((float)fileToSave.length() / MB)}); + String description = format.format(new Object[]{new Date(toCheck.lastModified()), ((float)toCheck.length() / MB)}); builder.setMessage(MessageFormat.format(getString(R.string.download_question_exist), regionName, description, e.getValue())); } diff --git a/OsmAnd/src/com/osmand/activities/search/SearchPOIActivity.java b/OsmAnd/src/com/osmand/activities/search/SearchPOIActivity.java index cbbee3d1fc..d8e3feb43a 100644 --- a/OsmAnd/src/com/osmand/activities/search/SearchPOIActivity.java +++ b/OsmAnd/src/com/osmand/activities/search/SearchPOIActivity.java @@ -132,8 +132,17 @@ public class SearchPOIActivity extends ListActivity implements SensorEventListen showOnMap.setEnabled(filter != null); if (filter != null) { amenityAdapter = new AmenityAdapter(new ArrayList()); + if(location == null){ + filter.clearPreviousZoom(); + } else { + searchedLocation = location; + amenityAdapter.setNewModel(filter.initializeNewSearch(location.getLatitude(), location.getLongitude(), 40)); + } setListAdapter(amenityAdapter); + searchPOILevel.setEnabled(filter.isSearchFurtherAvailable()); searchArea.setText(filter.getSearchArea()); + } else { + searchPOILevel.setEnabled(false); } // ListActivity has a ListView, which you can get with: ListView lv = getListView(); @@ -159,7 +168,7 @@ public class SearchPOIActivity extends ListActivity implements SensorEventListen if (l != null && filter != null) { if (location == null) { searchedLocation = l; - amenityAdapter.setNewModel(filter.initializeNewSearch(l.getLatitude(), l.getLongitude(), 40)); + amenityAdapter.setNewModel(filter.searchAgain(l.getLatitude(), l.getLongitude())); searchPOILevel.setText(R.string.search_POI_level_btn); searchPOILevel.setEnabled(filter.isSearchFurtherAvailable()); searchArea.setText(filter.getSearchArea()); @@ -284,13 +293,6 @@ public class SearchPOIActivity extends ListActivity implements SensorEventListen super.onResume(); if(searchNearBy){ location = null; - } - if (filter != null && location != null) { - searchedLocation = location; - amenityAdapter.setNewModel(filter.initializeNewSearch(location.getLatitude(), location.getLongitude(), 40)); - searchPOILevel.setEnabled(filter.isSearchFurtherAvailable()); - searchArea.setText(filter.getSearchArea()); - } else { amenityAdapter.notifyDataSetChanged(); searchPOILevel.setEnabled(false); } @@ -299,7 +301,6 @@ public class SearchPOIActivity extends ListActivity implements SensorEventListen } else { searchPOILevel.setText(R.string.search_POI_level_btn); } - showOnMap.setEnabled(filter != null); if (searchNearBy) { LocationManager service = (LocationManager) getSystemService(LOCATION_SERVICE); service.requestLocationUpdates(LocationManager.GPS_PROVIDER, GPS_TIMEOUT_REQUEST, GPS_DIST_REQUEST, gpsListener); diff --git a/OsmAnd/src/com/osmand/views/AnimateDraggingMapThread.java b/OsmAnd/src/com/osmand/views/AnimateDraggingMapThread.java index 9a263426c1..13f3055f66 100644 --- a/OsmAnd/src/com/osmand/views/AnimateDraggingMapThread.java +++ b/OsmAnd/src/com/osmand/views/AnimateDraggingMapThread.java @@ -184,6 +184,7 @@ public class AnimateDraggingMapThread implements Runnable { public void startMoving(double curLat, double curLon, double finalLat, double finalLon, int curZoom, int endZoom, int tileSize, boolean notifyListener){ stopAnimatingSync(); this.notifyListener = notifyListener; + curZ = curZoom; intZ = curZoom; moveX = (float) ((MapUtils.getTileNumberX(intZ, curLon) - MapUtils.getTileNumberX(intZ, finalLon)) * tileSize); moveY = (float) ((MapUtils.getTileNumberY(intZ, curLat) - MapUtils.getTileNumberY(intZ, finalLat)) * tileSize); @@ -204,6 +205,7 @@ public class AnimateDraggingMapThread implements Runnable { } else { dirZ = -1; } + endZ = endZoom; timeZInt = Math.abs(curZoom - intZ) * 300; diff --git a/OsmAnd/src/com/osmand/views/OsmandMapTileView.java b/OsmAnd/src/com/osmand/views/OsmandMapTileView.java index c6567c3622..2549c13c46 100644 --- a/OsmAnd/src/com/osmand/views/OsmandMapTileView.java +++ b/OsmAnd/src/com/osmand/views/OsmandMapTileView.java @@ -315,7 +315,7 @@ public class OsmandMapTileView extends SurfaceView implements IMapDownloaderCall //////////////////////////////// DRAWING MAP PART ///////////////////////////////////////////// protected void drawEmptyTile(Canvas cvs, float x, float y){ - int tileDiv = (int) (getTileSize() / emptyTileDivisor); + float tileDiv = (getTileSize() / emptyTileDivisor); for (int k1 = 0; k1 < emptyTileDivisor; k1++) { for (int k2 = 0; k2 < emptyTileDivisor; k2++) { float xk = x + tileDiv* k1 ;