Skip to content

Commit 4b83037

Browse files
pshmaskara
authored andcommitted
Map marker selection and footer visibility now track together.
1 parent 353be8c commit 4b83037

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

app/src/main/java/fr/free/nrw/commons/nearby/NearbyMapFragment.java

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
import com.google.gson.GsonBuilder;
2525
import com.google.gson.reflect.TypeToken;
2626
import com.mapbox.mapboxsdk.Mapbox;
27+
import com.mapbox.mapboxsdk.annotations.Marker;
2728
import com.mapbox.mapboxsdk.annotations.MarkerOptions;
2829
import com.mapbox.mapboxsdk.annotations.PolygonOptions;
2930
import com.mapbox.mapboxsdk.camera.CameraPosition;
@@ -77,6 +78,7 @@ public class NearbyMapFragment extends android.support.v4.app.Fragment {
7778
private Animation rotate_forward;
7879

7980
private Place place;
81+
private Marker selected;
8082

8183
public NearbyMapFragment() {
8284
}
@@ -136,6 +138,8 @@ public void onViewCreated(View view, @Nullable Bundle savedInstanceState) {
136138
else if (bottomSheetDetailsBehavior.getState() == BottomSheetBehavior
137139
.STATE_COLLAPSED) {
138140
bottomSheetDetailsBehavior.setState(BottomSheetBehavior.STATE_HIDDEN);
141+
mapView.getMapAsync(MapboxMap::deselectMarkers);
142+
selected=null;
139143
return true;
140144
}
141145
}
@@ -253,8 +257,15 @@ private void setupMapView(Bundle savedInstanceState) {
253257
mapView.getMapAsync(mapboxMap -> {
254258
mapboxMap.addMarkers(baseMarkerOptions);
255259

260+
mapboxMap.setOnInfoWindowCloseListener(marker -> {
261+
if (marker == selected){
262+
bottomSheetDetailsBehavior.setState(BottomSheetBehavior.STATE_HIDDEN);
263+
}
264+
});
265+
256266
mapboxMap.setOnMarkerClickListener(marker -> {
257267
if (marker instanceof NearbyMarker) {
268+
this.selected = marker;
258269
NearbyMarker nearbyMarker = (NearbyMarker) marker;
259270
Place place = nearbyMarker.getNearbyBaseMarker().getPlace();
260271
passInfoToSheet(place);
@@ -328,6 +339,7 @@ public void prepareViewsForSheetPosition(int bottomSheetState) {
328339
this.getView().requestFocus();
329340
break;
330341
case (BottomSheetBehavior.STATE_HIDDEN):
342+
mapView.getMapAsync(MapboxMap::deselectMarkers);
331343
transparentView.setClickable(false);
332344
transparentView.setAlpha(0);
333345
closeFabs(isFabOpen);

0 commit comments

Comments
 (0)