@lugg/maps 1.0.0-beta.12 → 1.0.0-beta.13

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -8,6 +8,7 @@ import com.google.android.gms.maps.model.Polyline
8
8
 
9
9
  interface LuggPolylineViewDelegate {
10
10
  fun polylineViewDidUpdate(polylineView: LuggPolylineView)
11
+ fun polylineViewDidDrop(polylineView: LuggPolylineView)
11
12
  }
12
13
 
13
14
  data class AnimatedOptions(val duration: Long = 2150L, val easing: String = "linear", val trailLength: Float = 1f, val delay: Long = 0L)
@@ -67,8 +68,8 @@ class LuggPolylineView(context: Context) : ReactViewGroup(context) {
67
68
  }
68
69
 
69
70
  fun onDropViewInstance() {
71
+ delegate?.polylineViewDidDrop(this)
70
72
  delegate = null
71
- polyline?.remove()
72
73
  polyline = null
73
74
  }
74
75
  }
@@ -598,6 +598,10 @@ class GoogleMapProvider(private val context: Context) :
598
598
  syncPolylineView(polylineView)
599
599
  }
600
600
 
601
+ override fun polylineViewDidDrop(polylineView: LuggPolylineView) {
602
+ teardownPolyline(polylineView)
603
+ }
604
+
601
605
  // endregion
602
606
 
603
607
  // region PolygonViewDelegate
@@ -773,8 +777,12 @@ class GoogleMapProvider(private val context: Context) :
773
777
  }
774
778
 
775
779
  override fun removePolylineView(polylineView: LuggPolylineView) {
776
- polylineAnimators[polylineView]?.destroy()
777
- polylineAnimators.remove(polylineView)
780
+ teardownPolyline(polylineView)
781
+ }
782
+
783
+ private fun teardownPolyline(polylineView: LuggPolylineView) {
784
+ pendingPolylineViews.remove(polylineView)
785
+ polylineAnimators.remove(polylineView)?.destroy()
778
786
  polylineView.polyline?.remove()
779
787
  polylineView.polyline = null
780
788
  }
@@ -812,6 +820,8 @@ class GoogleMapProvider(private val context: Context) :
812
820
  private fun addPolylineViewToMap(polylineView: LuggPolylineView) {
813
821
  val map = googleMap ?: return
814
822
 
823
+ polylineAnimators.remove(polylineView)?.destroy()
824
+
815
825
  val options = PolylineOptions()
816
826
  .width(polylineView.strokeWidth.dpToPx())
817
827
  .zIndex(polylineView.zIndex)
@@ -249,7 +249,7 @@ class PolylineAnimator {
249
249
  // Clear spans before setting points to prevent IndexOutOfBoundsException
250
250
  // when the new points list is shorter than what existing spans reference
251
251
  poly.color = strokeColors.firstOrNull() ?: Color.BLACK
252
- poly.points = ArrayList(reusablePoints)
252
+ poly.points = reusablePoints
253
253
 
254
254
  if (strokeColors.size > 1) {
255
255
  val segmentCount = reusablePoints.size - 1
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lugg/maps",
3
- "version": "1.0.0-beta.12",
3
+ "version": "1.0.0-beta.13",
4
4
  "description": "Universal maps for React Native.",
5
5
  "main": "./lib/module/index.js",
6
6
  "types": "./lib/typescript/src/index.d.ts",