fix small issues

git-svn-id: https://osmand.googlecode.com/svn/trunk@318 e29c36b1-1cfa-d876-8d93-3434fc2bb7b8
This commit is contained in:
Victor Shcherb 2010-07-11 10:33:25 +00:00
parent 421f12a35a
commit 0d3650e693
5 changed files with 34 additions and 17 deletions

View file

@ -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<Amenity> 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<Amenity> amenityList = ResourceManager.getResourceManager().searchAmenities(this, lat, lon, zoom, maxCount);
return zoom;
}
public List<Amenity> initializeNewSearch(double lat, double lon, int firstTimeLimit){
zoom = getInitialZoom();
List<Amenity> 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<Amenity> searchAgain(double lat, double lon){
List<Amenity> amenityList = ResourceManager.getResourceManager().searchAmenities(this, lat, lon, zoom, maxCount);
int limit = -1;
if(zoom == getInitialZoom()){
limit = maxInitialCount;
}
List<Amenity> amenityList = ResourceManager.getResourceManager().searchAmenities(this, lat, lon, zoom, limit);
MapUtils.sortListOfMapObject(amenityList, lat, lon);
return amenityList;
}

View file

@ -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()));
}

View file

@ -132,8 +132,17 @@ public class SearchPOIActivity extends ListActivity implements SensorEventListen
showOnMap.setEnabled(filter != null);
if (filter != null) {
amenityAdapter = new AmenityAdapter(new ArrayList<Amenity>());
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);

View file

@ -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;

View file

@ -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 ;