I\'m getting some reports back from user experience through crashlytics giving me an error
Fatal Exception java.lang.NullPointerException
CameraU
Something from my MapUtil
, that handles this case:
public static void animateCamera(final MapView mapView, final GoogleMap map, final LatLng location) {
try{
CameraUpdate cameraUpdate = CameraUpdateFactory.newLatLngZoom(location, getBetterZoom(map));
map.animateCamera(cameraUpdate);
}catch(Exception e) {
MapsInitializer.initialize(mapView.getContext());
if (mapView.getViewTreeObserver().isAlive()) {
mapView.getViewTreeObserver().addOnGlobalLayoutListener(new OnGlobalLayoutListener() {
@SuppressLint("NewApi")
@Override
public void onGlobalLayout() {
GlobalyLayoutListenerUtil.removeGlobalLayoutListener(mapView, this);
animateCamera(mapView, mapView.getMap(), location);
}
});
} else {
if(map != null){
map.setOnMapLoadedCallback(new GoogleMap.OnMapLoadedCallback() {
@Override
public void onMapLoaded() {
if(location != null){
animateCamera(mapView, mapView.getMap(), location);
}
}
});
}
}
}
}