@@ -689,7 +689,7 @@ public void remove(boolean priority, Marker m) {
689
689
*/
690
690
public void animate (MarkerWithPosition marker , LatLng from , LatLng to ) {
691
691
lock .lock ();
692
- AnimationTask task = new AnimationTask (marker , from , to );
692
+ AnimationTask task = new AnimationTask (marker , from , to , lock );
693
693
694
694
for (AnimationTask existingTask : ongoingAnimations ) {
695
695
if (existingTask .marker .getId ().equals (task .marker .getId ())) {
@@ -713,7 +713,7 @@ public void animate(MarkerWithPosition marker, LatLng from, LatLng to) {
713
713
*/
714
714
public void animateThenRemove (MarkerWithPosition marker , LatLng from , LatLng to ) {
715
715
lock .lock ();
716
- AnimationTask animationTask = new AnimationTask (marker , from , to );
716
+ AnimationTask animationTask = new AnimationTask (marker , from , to , lock );
717
717
for (AnimationTask existingTask : ongoingAnimations ) {
718
718
if (existingTask .marker .getId ().equals (animationTask .marker .getId ())) {
719
719
existingTask .cancel ();
@@ -1188,11 +1188,14 @@ private class AnimationTask extends AnimatorListenerAdapter implements ValueAnim
1188
1188
private MarkerManager mMarkerManager ;
1189
1189
private ValueAnimator valueAnimator ;
1190
1190
1191
- private AnimationTask (MarkerWithPosition markerWithPosition , LatLng from , LatLng to ) {
1191
+ private final Lock lock ;
1192
+
1193
+ private AnimationTask (MarkerWithPosition markerWithPosition , LatLng from , LatLng to , Lock lock ) {
1192
1194
this .markerWithPosition = markerWithPosition ;
1193
1195
this .marker = markerWithPosition .marker ;
1194
1196
this .from = from ;
1195
1197
this .to = to ;
1198
+ this .lock = lock ;
1196
1199
}
1197
1200
1198
1201
public void perform () {
@@ -1209,10 +1212,15 @@ public void cancel() {
1209
1212
new Handler (Looper .getMainLooper ()).post (this ::cancel );
1210
1213
return ;
1211
1214
}
1212
- markerWithPosition .position = to ;
1213
- mRemoveOnComplete = false ;
1214
- valueAnimator .cancel ();
1215
- ongoingAnimations .remove (this );
1215
+ try {
1216
+ markerWithPosition .position = to ;
1217
+ mRemoveOnComplete = false ;
1218
+ valueAnimator .cancel ();
1219
+ lock .lock ();
1220
+ ongoingAnimations .remove (this );
1221
+ } finally {
1222
+ lock .unlock ();
1223
+ }
1216
1224
}
1217
1225
1218
1226
@ Override
@@ -1225,7 +1233,9 @@ public void onAnimationEnd(Animator animation) {
1225
1233
markerWithPosition .position = to ;
1226
1234
1227
1235
// Remove the task from the queue
1236
+ lock .lock ();
1228
1237
ongoingAnimations .remove (this );
1238
+ lock .unlock ();
1229
1239
}
1230
1240
1231
1241
public void removeOnAnimationComplete (MarkerManager markerManager ) {
0 commit comments