mirror of
https://github.com/commons-app/apps-android-commons.git
synced 2025-10-26 12:23:58 +01:00
fix: map crash (fixes #6432)
This commit is contained in:
parent
4ed9ad5085
commit
2056dfe4eb
1 changed files with 8 additions and 6 deletions
|
|
@ -963,13 +963,17 @@ class ExploreMapFragment : CommonsDaggerSupportFragment(), ExploreMapContract.Vi
|
||||||
if (geoPoint != null) {
|
if (geoPoint != null) {
|
||||||
binding!!.mapView.controller.setCenter(geoPoint)
|
binding!!.mapView.controller.setCenter(geoPoint)
|
||||||
val overlays = binding!!.mapView.overlays
|
val overlays = binding!!.mapView.overlays
|
||||||
|
// colllects the indices of items to remove
|
||||||
|
val indicesToRemove = mutableListOf<Int>()
|
||||||
for (i in overlays.indices) {
|
for (i in overlays.indices) {
|
||||||
if (overlays[i] is Marker) {
|
if (overlays[i] is Marker || overlays[i] is ScaleDiskOverlay) {
|
||||||
binding!!.mapView.overlays.removeAt(i)
|
indicesToRemove.add(i)
|
||||||
} else if (overlays[i] is ScaleDiskOverlay) {
|
|
||||||
binding!!.mapView.overlays.removeAt(i)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
// removes tha items in reverse order to avoid index shifting
|
||||||
|
indicesToRemove.sortedDescending().forEach { index ->
|
||||||
|
binding!!.mapView.overlays.removeAt(index)
|
||||||
|
}
|
||||||
val diskOverlay = ScaleDiskOverlay(
|
val diskOverlay = ScaleDiskOverlay(
|
||||||
requireContext(),
|
requireContext(),
|
||||||
geoPoint, 2000, GeoConstants.UnitOfMeasure.foot
|
geoPoint, 2000, GeoConstants.UnitOfMeasure.foot
|
||||||
|
|
@ -979,7 +983,6 @@ class ExploreMapFragment : CommonsDaggerSupportFragment(), ExploreMapContract.Vi
|
||||||
this.style = Paint.Style.STROKE
|
this.style = Paint.Style.STROKE
|
||||||
this.strokeWidth = 2f
|
this.strokeWidth = 2f
|
||||||
})
|
})
|
||||||
|
|
||||||
setCirclePaint1(Paint().apply {
|
setCirclePaint1(Paint().apply {
|
||||||
setColor(Color.argb(40, 128, 128, 128))
|
setColor(Color.argb(40, 128, 128, 128))
|
||||||
this.style = Paint.Style.FILL_AND_STROKE
|
this.style = Paint.Style.FILL_AND_STROKE
|
||||||
|
|
@ -988,7 +991,6 @@ class ExploreMapFragment : CommonsDaggerSupportFragment(), ExploreMapContract.Vi
|
||||||
setDisplaySizeMax(1700)
|
setDisplaySizeMax(1700)
|
||||||
}
|
}
|
||||||
binding!!.mapView.overlays.add(diskOverlay)
|
binding!!.mapView.overlays.add(diskOverlay)
|
||||||
|
|
||||||
val startMarker = Marker(
|
val startMarker = Marker(
|
||||||
binding!!.mapView
|
binding!!.mapView
|
||||||
).apply {
|
).apply {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue