Fix zoom issues

This commit is contained in:
Victor Shcherb 2012-10-10 23:35:36 +02:00
parent 3323fc77ad
commit ac961aa688
3 changed files with 20 additions and 10 deletions

View file

@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<classpath> <classpath>
<classpathentry kind="src" path="src"/> <classpathentry kind="src" path="src"/>
<classpathentry excluding="net/osmand/LogUtil.java|net/osmand/swing/|net/osmand/data/preparation/|net/osmand/osm/util/|net/osmand/data/index/|net/osmand/osm/io/OsmStorageWriter.java|resources/|net/osmand/router/test/" kind="src" path="use"/> <classpathentry excluding="net/osmand/LogUtil.java|net/osmand/swing/|net/osmand/data/preparation/|net/osmand/osm/util/|net/osmand/data/index/|net/osmand/osm/io/OsmStorageWriter.java|resources/|net/osmand/router/test/|rtree/" kind="src" path="use"/>
<classpathentry kind="src" path="gen"/> <classpathentry kind="src" path="gen"/>
<classpathentry kind="con" path="com.android.ide.eclipse.adt.ANDROID_FRAMEWORK"/> <classpathentry kind="con" path="com.android.ide.eclipse.adt.ANDROID_FRAMEWORK"/>
<classpathentry exported="true" kind="con" path="com.android.ide.eclipse.adt.LIBRARIES"/> <classpathentry exported="true" kind="con" path="com.android.ide.eclipse.adt.LIBRARIES"/>

View file

@ -47,6 +47,7 @@ public class ContextMenuLayer extends OsmandMapLayer {
private final String KEY_DESCRIPTION = "context_menu_description"; private final String KEY_DESCRIPTION = "context_menu_description";
private final String KEY_SELECTED_OBJECTS = "context_menu_selected_objects"; private final String KEY_SELECTED_OBJECTS = "context_menu_selected_objects";
private LatLon latLon; private LatLon latLon;
private String description;
private Map<Object, IContextMenuProvider> selectedObjects = new LinkedHashMap<Object, IContextMenuProvider>(); private Map<Object, IContextMenuProvider> selectedObjects = new LinkedHashMap<Object, IContextMenuProvider>();
private TextView textView; private TextView textView;
@ -64,6 +65,13 @@ public class ContextMenuLayer extends OsmandMapLayer {
public ContextMenuLayer(MapActivity activity){ public ContextMenuLayer(MapActivity activity){
this.activity = activity; this.activity = activity;
if(activity.getLastNonConfigurationInstanceByKey(KEY_LAT_LAN) != null) {
latLon = (LatLon) activity.getLastNonConfigurationInstanceByKey(KEY_LAT_LAN);
description = (String) activity.getLastNonConfigurationInstanceByKey(KEY_DESCRIPTION);
if(activity.getLastNonConfigurationInstanceByKey(KEY_SELECTED_OBJECTS) != null) {
selectedObjects = (Map<Object, IContextMenuProvider>) activity.getLastNonConfigurationInstanceByKey(KEY_SELECTED_OBJECTS);
}
}
} }
@Override @Override
@ -108,13 +116,10 @@ public class ContextMenuLayer extends OsmandMapLayer {
closeButton.setLayoutParams(lp); closeButton.setLayoutParams(lp);
closeButton.setImageDrawable(view.getResources().getDrawable(R.drawable.headliner_close)); closeButton.setImageDrawable(view.getResources().getDrawable(R.drawable.headliner_close));
closeButton.setClickable(true); closeButton.setClickable(true);
if(latLon != null){
setLocation(latLon, description);
}
if(activity.getLastNonConfigurationInstanceByKey(KEY_LAT_LAN) != null && activity.getLastNonConfigurationInstanceByKey(KEY_DESCRIPTION) != null) {
setLocation((LatLon)activity.getLastNonConfigurationInstanceByKey(KEY_LAT_LAN), (String) activity.getLastNonConfigurationInstanceByKey(KEY_DESCRIPTION));
if(activity.getLastNonConfigurationInstanceByKey(KEY_SELECTED_OBJECTS) != null) {
selectedObjects = (Map<Object, IContextMenuProvider>) activity.getLastNonConfigurationInstanceByKey(KEY_SELECTED_OBJECTS);
}
}
} }
@Override @Override
@ -378,7 +383,7 @@ public class ContextMenuLayer extends OsmandMapLayer {
public void onRetainNonConfigurationInstance(Map<String, Object> map) { public void onRetainNonConfigurationInstance(Map<String, Object> map) {
map.put(KEY_LAT_LAN, latLon); map.put(KEY_LAT_LAN, latLon);
map.put(KEY_SELECTED_OBJECTS, selectedObjects); map.put(KEY_SELECTED_OBJECTS, selectedObjects);
map.put(KEY_SELECTED_OBJECTS, textView.getText().toString()); map.put(KEY_DESCRIPTION, textView.getText().toString());
} }
} }

View file

@ -285,7 +285,12 @@ public class OsmandMapTileView extends SurfaceView implements IMapDownloaderCall
if (mainLayer != null && zoom <= mainLayer.getMaximumShownMapZoom() + 0.01 && zoom >= mainLayer.getMinimumShownMapZoom() - 0.01) { if (mainLayer != null && zoom <= mainLayer.getMaximumShownMapZoom() + 0.01 && zoom >= mainLayer.getMinimumShownMapZoom() - 0.01) {
animatedDraggingThread.stopAnimating(); animatedDraggingThread.stopAnimating();
// avoid round error // avoid round error
if(zoom < Math.round(zoom)){
this.zoom = zoom + 0.001f; this.zoom = zoom + 0.001f;
} else {
this.zoom = zoom;
}
refreshMap(); refreshMap();
} }
} }
@ -343,7 +348,7 @@ public class OsmandMapTileView extends SurfaceView implements IMapDownloaderCall
public boolean isZooming(){ public boolean isZooming(){
// zooming scale // zooming scale
float diff = (zoom - getZoom()) * ZOOM_DELTA; float diff = (zoom - getZoom()) * ZOOM_DELTA;
if(Math.abs(diff - Math.round(diff)) < 0.0001) { if(Math.abs(diff - Math.round(diff)) < 0.02) {
return false; return false;
} }
return true; return true;