Skip to content

Commit 6f76f14

Browse files
pengdevgithub-actions[bot]
authored andcommitted
Fix location indicator bearing animation update being missing in some occasions. (#4464)
Avoid puck animation being disabled due the animator being reused and the onAnimationEnd would be triggered multiple times. cc @mapbox/maps-android GitOrigin-RevId: 1fcd1a65533da61c8265626edd2837156d6521f3
1 parent d6619d3 commit 6f76f14

File tree

2 files changed

+14
-4
lines changed

2 files changed

+14
-4
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,10 @@ Mapbox welcomes participation and contributions from everyone.
88
* Added new `FillLayer.fillPatternCrossFade`, `FillExtrusionLayer.fillExtrusionPatternCrossFade`, `LineLayer.fillExtrusionPatternCrossFade` properties.
99
* Improve the performance of `MapboxMap.cameraForCoordinates(...)` for large amounts of points.
1010

11+
# 11.13.0
12+
## Bug fixes 🐞
13+
* Fix location indicator bearing animation update being missing in some occasions.
14+
1115
# 11.12.3 June 05, 2025
1216
## Features ✨ and improvements 🏁
1317
* Improve the performance of `MapboxMap.cameraForCoordinates(...)` for large amounts of points.

plugin-locationcomponent/src/main/java/com/mapbox/maps/plugin/locationcomponent/LocationPuckManager.kt

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
11
package com.mapbox.maps.plugin.locationcomponent
22

3+
import android.animation.Animator
4+
import android.animation.AnimatorListenerAdapter
35
import android.animation.ValueAnimator
46
import android.content.Context
57
import androidx.annotation.RestrictTo
68
import androidx.annotation.VisibleForTesting
79
import androidx.annotation.VisibleForTesting.Companion.PRIVATE
8-
import androidx.core.animation.doOnEnd
910
import com.mapbox.bindgen.Value
1011
import com.mapbox.common.location.LocationError
1112
import com.mapbox.geojson.Point
@@ -45,6 +46,13 @@ internal class LocationPuckManager(
4546
lastBearing = it
4647
}
4748

49+
private val disablePuckAnimationOnEnd = object : AnimatorListenerAdapter() {
50+
override fun onAnimationEnd(animation: Animator) {
51+
animationManager.puckAnimationEnabled = false
52+
animation.removeListener(this)
53+
}
54+
}
55+
4856
private var lastAccuracyRadius: Double = 0.0
4957
private val onAccuracyRadiusUpdated: ((Double) -> Unit) = {
5058
lastAccuracyRadius = it
@@ -155,9 +163,7 @@ internal class LocationPuckManager(
155163
doubleArrayOf(0.0),
156164
options = {
157165
duration = 0
158-
doOnEnd {
159-
animationManager.puckAnimationEnabled = false
160-
}
166+
addListener(disablePuckAnimationOnEnd)
161167
},
162168
forceUpdate
163169
)

0 commit comments

Comments
 (0)