fix: map crash (fixes #6432) (#6479)

* fix: map crash (fixes #6432)

* Fix typos in comments in ExploreMapFragment.kt

---------

Co-authored-by: Nicolas Raoul <nicolas.raoul@gmail.com>
This commit is contained in:
VoidRaven 2025-10-11 11:08:07 +05:30 committed by GitHub
parent 0a4b179db5
commit adb6181e9f
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -963,13 +963,17 @@ class ExploreMapFragment : CommonsDaggerSupportFragment(), ExploreMapContract.Vi
if (geoPoint != null) {
binding!!.mapView.controller.setCenter(geoPoint)
val overlays = binding!!.mapView.overlays
// collects the indices of items to remove
val indicesToRemove = mutableListOf<Int>()
for (i in overlays.indices) {
if (overlays[i] is Marker) {
binding!!.mapView.overlays.removeAt(i)
} else if (overlays[i] is ScaleDiskOverlay) {
binding!!.mapView.overlays.removeAt(i)
if (overlays[i] is Marker || overlays[i] is ScaleDiskOverlay) {
indicesToRemove.add(i)
}
}
// removes the items in reverse order to avoid index shifting
indicesToRemove.sortedDescending().forEach { index ->
binding!!.mapView.overlays.removeAt(index)
}
val diskOverlay = ScaleDiskOverlay(
requireContext(),
geoPoint, 2000, GeoConstants.UnitOfMeasure.foot
@ -979,7 +983,6 @@ class ExploreMapFragment : CommonsDaggerSupportFragment(), ExploreMapContract.Vi
this.style = Paint.Style.STROKE
this.strokeWidth = 2f
})
setCirclePaint1(Paint().apply {
setColor(Color.argb(40, 128, 128, 128))
this.style = Paint.Style.FILL_AND_STROKE
@ -988,7 +991,6 @@ class ExploreMapFragment : CommonsDaggerSupportFragment(), ExploreMapContract.Vi
setDisplaySizeMax(1700)
}
binding!!.mapView.overlays.add(diskOverlay)
val startMarker = Marker(
binding!!.mapView
).apply {