forked from upstream-mirrors/OpenTracks
In MyTracksMapFragment, initialize googleMap in onActivityCreated instead of onCreateView.
This commit is contained in:
@@ -192,10 +192,23 @@ public class MyTracksMapFragment extends SupportMapFragment implements TrackData
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
messageTextView = (TextView) layout.findViewById(R.id.map_message);
|
messageTextView = (TextView) layout.findViewById(R.id.map_message);
|
||||||
|
return layout;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onActivityCreated(Bundle savedInstanceState) {
|
||||||
|
super.onActivityCreated(savedInstanceState);
|
||||||
|
if (savedInstanceState != null) {
|
||||||
|
keepCurrentLocationVisible = savedInstanceState.getBoolean(
|
||||||
|
KEEP_CURRENT_LOCATION_VISIBLE_KEY, false);
|
||||||
|
zoomToCurrentLocation = savedInstanceState.getBoolean(ZOOM_TO_CURRENT_LOCATION_KEY, false);
|
||||||
|
Location location = (Location) savedInstanceState.getParcelable(CURRENT_LOCATION_KEY);
|
||||||
|
setCurrentLocation(location);
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* At this point, after super.onCreateView, getMap will not return null and
|
* At this point, after onCreateView, getMap will not return null and we can
|
||||||
* we can initialize googleMap. However, onCreateView can be called multiple
|
* initialize googleMap. However, onActivityCreated can be called multiple
|
||||||
* times, e.g., when the user switches tabs. With
|
* times, e.g., when the user switches tabs. With
|
||||||
* GoogleMapOptions.useViewLifecycleInFragment == false, googleMap lifecycle
|
* GoogleMapOptions.useViewLifecycleInFragment == false, googleMap lifecycle
|
||||||
* is tied to the fragment lifecycle and the same googleMap object is
|
* is tied to the fragment lifecycle and the same googleMap object is
|
||||||
@@ -256,19 +269,6 @@ public class MyTracksMapFragment extends SupportMapFragment implements TrackData
|
|||||||
googleMap.moveCamera(
|
googleMap.moveCamera(
|
||||||
CameraUpdateFactory.newLatLngZoom(getDefaultLatLng(), googleMap.getMinZoomLevel()));
|
CameraUpdateFactory.newLatLngZoom(getDefaultLatLng(), googleMap.getMinZoomLevel()));
|
||||||
}
|
}
|
||||||
return layout;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onActivityCreated(Bundle savedInstanceState) {
|
|
||||||
super.onActivityCreated(savedInstanceState);
|
|
||||||
if (savedInstanceState != null) {
|
|
||||||
keepCurrentLocationVisible = savedInstanceState.getBoolean(
|
|
||||||
KEEP_CURRENT_LOCATION_VISIBLE_KEY, false);
|
|
||||||
zoomToCurrentLocation = savedInstanceState.getBoolean(ZOOM_TO_CURRENT_LOCATION_KEY, false);
|
|
||||||
Location location = (Location) savedInstanceState.getParcelable(CURRENT_LOCATION_KEY);
|
|
||||||
setCurrentLocation(location);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
Reference in New Issue
Block a user