Skip to content

Commit 096c075

Browse files
authored
Removed duplicate code in addMarkersToMap method (#5783)
1 parent a81d48c commit 096c075

File tree

1 file changed

+3
-45
lines changed

1 file changed

+3
-45
lines changed

app/src/main/java/fr/free/nrw/commons/nearby/fragments/NearbyParentFragment.java

Lines changed: 3 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -1992,51 +1992,9 @@ private void addMarkerToMap(Place place, Boolean isBookMarked) {
19921992
* locations.
19931993
*/
19941994
private void addMarkersToMap(List<BaseMarker> nearbyBaseMarkers) {
1995-
for (int i = 0; i < nearbyBaseMarkers.size(); i++) {
1996-
Drawable icon = ContextCompat.getDrawable(getContext(),
1997-
getIconFor(nearbyBaseMarkers.get(i).getPlace(), false));
1998-
GeoPoint point = new GeoPoint(
1999-
nearbyBaseMarkers.get(i).getPlace().location.getLatitude(),
2000-
nearbyBaseMarkers.get(i).getPlace().location.getLongitude());
2001-
Marker marker = new Marker(binding.map);
2002-
marker.setPosition(point);
2003-
marker.setIcon(icon);
2004-
Place place = nearbyBaseMarkers.get(i).getPlace();
2005-
if (!Objects.equals(place.name, "")) {
2006-
marker.setTitle(place.name);
2007-
marker.setSnippet(
2008-
containsParentheses(place.getLongDescription())
2009-
? getTextBetweenParentheses(
2010-
place.getLongDescription()) : place.getLongDescription());
2011-
}
2012-
marker.setTextLabelFontSize(40);
2013-
marker.setId(String.valueOf(i));
2014-
marker.setAnchor(Marker.ANCHOR_CENTER, Marker.ANCHOR_TOP);
2015-
marker.setOnMarkerClickListener((marker1, mapView) -> {
2016-
marker1.showInfoWindow();
2017-
if (clickedMarker != null) {
2018-
clickedMarker.closeInfoWindow();
2019-
}
2020-
clickedMarker = marker1;
2021-
int index = Integer.parseInt(marker1.getId());
2022-
Place updatedPlace = nearbyBaseMarkers.get(index).getPlace();
2023-
binding.bottomSheetDetails.dataCircularProgress.setVisibility(View.VISIBLE);
2024-
binding.bottomSheetDetails.icon.setVisibility(View.GONE);
2025-
binding.bottomSheetDetails.wikiDataLl.setVisibility(View.GONE);
2026-
if (Objects.equals(updatedPlace.name, "")) {
2027-
getPlaceData(updatedPlace.getWikiDataEntityId(), updatedPlace, marker1, false);
2028-
} else {
2029-
marker.showInfoWindow();
2030-
binding.bottomSheetDetails.dataCircularProgress.setVisibility(View.GONE);
2031-
binding.bottomSheetDetails.icon.setVisibility(View.VISIBLE);
2032-
binding.bottomSheetDetails.wikiDataLl.setVisibility(View.VISIBLE);
2033-
passInfoToSheet(place);
2034-
hideBottomSheet();
2035-
}
2036-
bottomSheetDetailsBehavior.setState(BottomSheetBehavior.STATE_COLLAPSED);
2037-
return true;
2038-
});
2039-
binding.map.getOverlays().add(marker);
1995+
1996+
for(int i = 0; i< nearbyBaseMarkers.size(); i++){
1997+
addMarkerToMap(nearbyBaseMarkers.get(i).getPlace(), false);
20401998
}
20411999
}
20422000

0 commit comments

Comments
 (0)