Skip to content

Commit e2db7b6

Browse files
author
Guillaume DROULEZ
committed
Crash in our App fix
java.lang.NullPointerException: Attempt to invoke virtual method 'com.google.android.gms.maps.Projection com.google.android.gms.maps.GoogleMap.getProjection()' on a null object reference at com.airbnb.android.react.maps.AirMapView$13.run(AirMapView.java:643) at android.os.Handler.handleCallback(Handler.java:739) at android.os.Handler.dispatchMessage(Handler.java:95) at android.os.Looper.loop(Looper.java:135) at android.app.ActivityThread.main(ActivityThread.java:5289) at java.lang.reflect.Method.invoke(Native Method) at java.lang.reflect.Method.invoke(Method.java:372) at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.ja va:899) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:694)
1 parent b89ce8d commit e2db7b6

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

android/src/main/java/com/airbnb/android/react/maps/AirMapView.java

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@
4141
import com.google.android.gms.maps.model.Marker;
4242
import com.google.android.gms.maps.model.Polygon;
4343
import com.google.android.gms.maps.model.Polyline;
44+
import com.google.android.gms.maps.model.VisibleRegion;
4445

4546
import java.util.ArrayList;
4647
import java.util.Arrays;
@@ -646,9 +647,12 @@ public void stopMonitoringRegion() {
646647
@Override
647648
public void run() {
648649

649-
LatLngBounds bounds = map.getProjection().getVisibleRegion().latLngBounds;
650-
if (lastBoundsEmitted == null ||
651-
LatLngBoundsUtils.BoundsAreDifferent(bounds, lastBoundsEmitted)) {
650+
Projection projection = map.getProjection();
651+
VisibleRegion region = (projection != null) ? projection.getVisibleRegion() : null;
652+
LatLngBounds bounds = (region != null) ? region.latLngBounds : null;
653+
654+
if ((bounds != null) &&
655+
(lastBoundsEmitted == null || LatLngBoundsUtils.BoundsAreDifferent(bounds, lastBoundsEmitted))) {
652656
LatLng center = map.getCameraPosition().target;
653657
lastBoundsEmitted = bounds;
654658
eventDispatcher.dispatchEvent(new RegionChangeEvent(getId(), bounds, center, true));

0 commit comments

Comments
 (0)