From 72342750c016bdb0da81b56ad15472290ad8120a Mon Sep 17 00:00:00 2001 From: Gustavo Martin Morcuende Date: Sun, 11 Jan 2015 01:39:40 +0100 Subject: [PATCH] MapFragment.getMapAsync and the Android screen rotate mess --- .../weather/information/activity/MapActivity.java | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/app/src/main/java/name/gumartinm/weather/information/activity/MapActivity.java b/app/src/main/java/name/gumartinm/weather/information/activity/MapActivity.java index c686982..7369196 100644 --- a/app/src/main/java/name/gumartinm/weather/information/activity/MapActivity.java +++ b/app/src/main/java/name/gumartinm/weather/information/activity/MapActivity.java @@ -194,6 +194,7 @@ public class MapActivity extends FragmentActivity implements // The Android rotate screen mess. this.mMapActivityOnMapReadyCallback.onDestroy(); + this.mButtonsUpdate.onDestroy(); } public void onClickSaveLocation(final View v) { @@ -474,10 +475,6 @@ public class MapActivity extends FragmentActivity implements this.mapActivity.mMap.animateCamera(CameraUpdateFactory.zoomIn()); this.mapActivity.mMap.animateCamera(CameraUpdateFactory.zoomTo(8), 2000, null); } - - private WeatherLocation getLocation() { - return this.weatherLocation; - } } private class ButtonsUpdate { @@ -488,6 +485,11 @@ public class MapActivity extends FragmentActivity implements } private void doUpdate() { + if (this.mapActivity == null) { + // Do nothing + return; + } + if (this.mapActivity.mMap == null) { final Button getLocationButton = (Button) this.mapActivity.findViewById(R.id.weather_map_button_getlocation); final Button saveLocationButton = (Button) this.mapActivity.findViewById(R.id.weather_map_button_savelocation); @@ -510,5 +512,9 @@ public class MapActivity extends FragmentActivity implements } } } + + private void onDestroy() { + this.mapActivity = null; + } } } -- 2.1.4