BUGFIX issue 85

git-svn-id: https://osmand.googlecode.com/svn/trunk@574 e29c36b1-1cfa-d876-8d93-3434fc2bb7b8
This commit is contained in:
Victor Shcherb 2010-10-15 22:56:11 +00:00
parent 0dd0475855
commit a9fe37c5b1

View file

@ -765,12 +765,7 @@ public class MapActivity extends Activity implements IMapLocationListener, Senso
super.onResume(); super.onResume();
if(OsmandSettings.getMapOrientation(settings) != getRequestedOrientation()){ if(OsmandSettings.getMapOrientation(settings) != getRequestedOrientation()){
setRequestedOrientation(OsmandSettings.getMapOrientation(settings)); setRequestedOrientation(OsmandSettings.getMapOrientation(settings));
// do nothing now (let recreate activity) // can't return from this method we are not sure if activity will be recreated or not
// only save map position
LatLon l = OsmandSettings.getLastKnownMapLocation(settings);
mapView.setLatLon(l.getLatitude(), l.getLongitude());
mapView.setZoom(OsmandSettings.getLastKnownMapZoom(settings));
return;
} }
currentScreenOrientation = getWindow().getWindowManager().getDefaultDisplay().getOrientation(); currentScreenOrientation = getWindow().getWindowManager().getDefaultDisplay().getOrientation();
@ -803,30 +798,24 @@ public class MapActivity extends Activity implements IMapLocationListener, Senso
providerSupportsBearing = prov == null ? false : prov.supportsBearing() && !isRunningOnEmulator(); providerSupportsBearing = prov == null ? false : prov.supportsBearing() && !isRunningOnEmulator();
providerSupportsSpeed = prov == null ? false : prov.supportsSpeed() && !isRunningOnEmulator(); providerSupportsSpeed = prov == null ? false : prov.supportsSpeed() && !isRunningOnEmulator();
if(settings != null && settings.contains(OsmandSettings.LAST_KNOWN_MAP_LAT)){
LatLon l = OsmandSettings.getLastKnownMapLocation(settings);
mapView.setLatLon(l.getLatitude(), l.getLongitude());
mapView.setZoom(OsmandSettings.getLastKnownMapZoom(settings));
}
if (wakeLock == null) { if (wakeLock == null) {
PowerManager powerManager = (PowerManager) getSystemService(POWER_SERVICE); PowerManager powerManager = (PowerManager) getSystemService(POWER_SERVICE);
wakeLock = powerManager.newWakeLock(PowerManager.SCREEN_BRIGHT_WAKE_LOCK, "net.osmand.map"); //$NON-NLS-1$ wakeLock = powerManager.newWakeLock(PowerManager.SCREEN_BRIGHT_WAKE_LOCK, "net.osmand.map"); //$NON-NLS-1$
wakeLock.acquire(); wakeLock.acquire();
} }
SharedPreferences prefs = getSharedPreferences(OsmandSettings.SHARED_PREFERENCES_NAME, MODE_WORLD_READABLE);
if(prefs != null && prefs.contains(OsmandSettings.LAST_KNOWN_MAP_LAT)){
LatLon l = OsmandSettings.getLastKnownMapLocation(settings);
mapView.setLatLon(l.getLatitude(), l.getLongitude());
mapView.setZoom(OsmandSettings.getLastKnownMapZoom(settings));
LatLon latLon = OsmandSettings.getAndClearMapLocationToShow(settings);
LatLon cur = new LatLon(mapView.getLatitude(), mapView.getLongitude());
if(latLon != null && !latLon.equals(cur)){
mapView.getAnimatedDraggingThread().startMoving(cur.getLatitude(), cur.getLongitude(),
latLon.getLatitude(), latLon.getLongitude(),
mapView.getZoom(), OsmandSettings.getMapZoomToShow(settings),
mapView.getSourceTileSize(), mapView.getRotate(), true);
}
}
OsmandSettings.setMapActivityEnabled(this, true); OsmandSettings.setMapActivityEnabled(this, true);
checkExternalStorage(); checkExternalStorage();
showAndHideMapPosition(); showAndHideMapPosition();
View progress = findViewById(R.id.ProgressBar); View progress = findViewById(R.id.ProgressBar);
if (progress == null) { if (progress == null) {
// strange solution (not reproducible) - that is workaround // strange solution (not reproducible) - that is workaround
@ -838,6 +827,19 @@ public class MapActivity extends Activity implements IMapLocationListener, Senso
} }
} }
@Override
public void onAttachedToWindow() {
super.onAttachedToWindow();
// start animate transition only ui appears (take into account that on resume orientation can change)
LatLon latLon = OsmandSettings.getAndClearMapLocationToShow(settings);
LatLon cur = new LatLon(mapView.getLatitude(), mapView.getLongitude());
if (latLon != null && !latLon.equals(cur)) {
mapView.getAnimatedDraggingThread().startMoving(cur.getLatitude(), cur.getLongitude(), latLon.getLatitude(),
latLon.getLongitude(), mapView.getZoom(), OsmandSettings.getMapZoomToShow(settings), mapView.getSourceTileSize(),
mapView.getRotate(), true);
}
}
@Override @Override
public boolean onKeyUp(int keyCode, KeyEvent event) { public boolean onKeyUp(int keyCode, KeyEvent event) {
if (keyCode == KeyEvent.KEYCODE_DPAD_CENTER) { if (keyCode == KeyEvent.KEYCODE_DPAD_CENTER) {