private void saveState() { IGeoPoint point = map.getMapCenter(); storage.writeInteger(solidKey + LONGITUDE_SUFFIX, point.getLongitudeE6()); storage.writeInteger(solidKey + LATITUDE_SUFFIX, point.getLatitudeE6()); storage.writeInteger(solidKey + ZOOM_SUFFIX, map.getZoomLevel()); }
private void loadState() { location = new GeoPoint( storage.readInteger(solidKey + LATITUDE_SUFFIX), storage.readInteger(solidKey + LONGITUDE_SUFFIX)); MapController controller = map.getController(); controller.setZoom(storage.readInteger(solidKey + ZOOM_SUFFIX)); controller.setCenter(location); }
private OsmInteractiveView( Context context, DispatcherInterface dispatcher, String key, DynTileProvider p) { super(context, p, new MapDensity(context)); // provider = p; solidKey = key; storage = Storage.global(context); slock = new SolidPositionLock(context, solidKey); map.setMapListener(this); map.setOnTouchListener(this); loadState(); dispatcher.addTarget(this, InfoID.LOCATION); }
@Override public void onAttachedToWindow() { super.onAttachedToWindow(); storage.register(this); }
@Override public void onDetachedFromWindow() { saveState(); storage.unregister(this); super.onDetachedFromWindow(); }