Skip to content

Commit

Permalink
Prevent NullPointerExceptions when the activity is null (#2982)
Browse files Browse the repository at this point in the history
For example, during an orientation change.
  • Loading branch information
lognaturel authored and grzesiek2010 committed Apr 2, 2019
1 parent 3ea775e commit 8748be4
Showing 1 changed file with 5 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -327,7 +327,10 @@ protected void moveOrAnimateCamera(CameraUpdate movement, boolean animate) {
if (gpsLocationListener != null) {
gpsLocationListener.onPoint(lastLocationFix);
}
updateLocationIndicator(toLatLng(lastLocationFix), location.getAccuracy());

if (getActivity() != null) {
updateLocationIndicator(toLatLng(lastLocationFix), location.getAccuracy());
}
}

protected void updateLocationIndicator(LatLng loc, double radius) {
Expand Down Expand Up @@ -483,7 +486,7 @@ protected void updateFeature(int featureId) {
}

protected Marker createMarker(GoogleMap map, MapPoint point, boolean draggable) {
if (map == null) { // during Robolectric tests, map will be null
if (map == null || getActivity() == null) { // during Robolectric tests, map will be null
return null;
}
// A Marker's position is a LatLng with just latitude and longitude
Expand Down

0 comments on commit 8748be4

Please sign in to comment.