Repository: google/ground-android
Issue: [Join Project] No such element exception

**Describe the bug**
When joining a project, Ground sometimes throws a "No Such Element" exception when setting map features.

**To Reproduce**
Steps to reproduce the behavior:
1. Go to 'Join Project'
2. Click on a project
4. See error (potentially)

**Stacktrace**

```
2021-09-30 16:46:29.082 5636-5636/com.google.android.gnd E/AndroidRuntime: FATAL EXCEPTION: main
    Process: com.google.android.gnd, PID: 5636
    java.util.NoSuchElementException
        at java.util.HashMap$HashIterator.nextNode(HashMap.java:1443)
        at java.util.HashMap$EntryIterator.next(HashMap.java:1475)
        at java.util.HashMap$EntryIterator.next(HashMap.java:1473)
        at com.google.android.gnd.ui.map.gms.GoogleMapsMapAdapter.setMapFeatures(GoogleMapsMapAdapter.java:359)
        at com.google.android.gnd.ui.home.mapcontainer.-$$Lambda$Gpu9kEZxCjyf8AhAC-rOJIqwKEI.onChanged(Unknown Source:4)
        at androidx.lifecycle.LiveData.considerNotify(LiveData.java:133)
        at androidx.lifecycle.LiveData.dispatchingValue(LiveData.java:151)
        at androidx.lifecycle.LiveData.setValue(LiveData.java:309)
        at androidx.lifecycle.LiveData$1.run(LiveData.java:93)
        at android.os.Handler.handleCallback(Handler.java:873)
        at android.os.Handler.dispatchMessage(Handler.java:99)
        at android.os.Looper.loop(Looper.java:193)
        at android.app.ActivityThread.main(ActivityThread.java:6669)
        at java.lang.reflect.Method.invoke(Native Method)
        at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:493)
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:858)
```

Changed files:
gnd/src/main/java/com/google/android/gnd/ui/map/gms/GoogleMapsMapAdapter.java

diff --git a/gnd/src/main/java/com/google/android/gnd/ui/map/gms/GoogleMapsMapAdapter.java b/gnd/src/main/java/com/google/android/gnd/ui/map/gms/GoogleMapsMapAdapter.java
index 3327fe2c3..e31cdfc5a 100644
--- a/gnd/src/main/java/com/google/android/gnd/ui/map/gms/GoogleMapsMapAdapter.java
+++ b/gnd/src/main/java/com/google/android/gnd/ui/map/gms/GoogleMapsMapAdapter.java
@@ -166,8 +166,7 @@ class GoogleMapsMapAdapter implements MapAdapter {
     Builder<MapFeature> candidates = ImmutableList.builder();
     ArrayList<String> processed = new ArrayList<>();
 
-    for (Entry<MapFeature, GeometryCollection> geoJsonEntry :
-        geoJsonGeometries.entrySet()) {
+    for (Entry<MapFeature, GeometryCollection> geoJsonEntry : geoJsonGeometries.entrySet()) {
       MapGeoJson geoJsonFeature = (MapGeoJson) geoJsonEntry.getKey();
       GeometryCollection geoJsonGeometry = geoJsonEntry.getValue();
       if (processed.contains(geoJsonFeature.getId())) {
@@ -279,8 +278,7 @@ class GoogleMapsMapAdapter implements MapAdapter {
     LatLng position = toLatLng(mapPin.getPosition());
     String color = mapPin.getStyle().getColor();
     BitmapDescriptor icon = markerIconFactory.getMarkerIcon(parseColor(color));
-    Marker marker =
-        map.addMarker(new MarkerOptions().position(position).icon(icon).alpha(1.0f));
+    Marker marker = map.addMarker(new MarkerOptions().position(position).icon(icon).alpha(1.0f));
     markers.add(marker);
     marker.setTag(mapPin);
   }
@@ -355,8 +353,9 @@ class GoogleMapsMapAdapter implements MapAdapter {
 
     Iterator<Entry<MapFeature, Polyline>> polylineIterator = polygons.entrySet().iterator();
     while (polylineIterator.hasNext()) {
-      MapFeature mapFeature = polylineIterator.next().getKey();
-      Polyline polyline = polylineIterator.next().getValue();
+      Entry<MapFeature, Polyline> entry = polylineIterator.next();
+      MapFeature mapFeature = entry.getKey();
+      Polyline polyline = entry.getValue();
       if (features.contains(mapFeature)) {
         // If polygon already exists on map, don't add it.
         featuresToUpdate.remove(mapFeature);
@@ -484,9 +483,7 @@ class GoogleMapsMapAdapter implements MapAdapter {
     stream(urls).forEach(this::addRemoteTileOverlay);
   }
 
-  /**
-   * A collection of geometries in a GeoJson feature.
-   */
+  /** A collection of geometries in a GeoJson feature. */
   private class GeometryCollection {
     List<Marker> markers = new ArrayList<>();
     List<Polyline> polylines = new ArrayList<>();
@@ -549,10 +546,7 @@ class GoogleMapsMapAdapter implements MapAdapter {
     }
 
     private Marker addMarker(GeoJsonPoint point) {
-      return map.addMarker(
-          new MarkerOptions()
-              .zIndex(1)
-              .position(point.getCoordinates()));
+      return map.addMarker(new MarkerOptions().zIndex(1).position(point.getCoordinates()));
     }
 
     private Polyline addPolyline(GeoJsonLineString lineString, float width, int color) {
@@ -565,12 +559,13 @@ class GoogleMapsMapAdapter implements MapAdapter {
     }
 
     private Polygon addPolygon(GeoJsonPolygon dataPolygon, float width, int color) {
-      PolygonOptions polygonOptions = new PolygonOptions()
-          .addAll(dataPolygon.getOuterBoundaryCoordinates())
-          .strokeWidth(width)
-          .strokeColor(color)
-          .clickable(false)
-          .zIndex(1);
+      PolygonOptions polygonOptions =
+          new PolygonOptions()
+              .addAll(dataPolygon.getOuterBoundaryCoordinates())
+              .strokeWidth(width)
+              .strokeColor(color)
+              .clickable(false)
+              .zIndex(1);
       for (List<LatLng> innerBoundary : dataPolygon.getInnerBoundaryCoordinates()) {
         polygonOptions.addHole(innerBoundary);
       }
@@ -583,7 +578,7 @@ class GoogleMapsMapAdapter implements MapAdapter {
     GeoJsonParser geoJsonParser = new GeoJsonParser(mapFeature.getGeoJson());
     GeometryCollection featureGeometries = new GeometryCollection();
     geoJsonGeometries.put(mapFeature, featureGeometries);
-    for (GeoJsonFeature geoJsonFeature: geoJsonParser.getFeatures()) {
+    for (GeoJsonFeature geoJsonFeature : geoJsonParser.getFeatures()) {
       featureGeometries.addGeometry(mapFeature, geoJsonFeature.getGeometry());
     }
   }