android: fix cancel cause modify map concurrently

This commit is contained in:
pengfei.zhou 2021-12-24 15:29:37 +08:00 committed by osborn
parent 48afc3acb3
commit 24e704e1b9

View File

@ -33,6 +33,7 @@ import java.util.ArrayList;
import java.util.Collection; import java.util.Collection;
import java.util.HashMap; import java.util.HashMap;
import java.util.Map; import java.util.Map;
import java.util.Set;
import java.util.WeakHashMap; import java.util.WeakHashMap;
import java.util.concurrent.Callable; import java.util.concurrent.Callable;
@ -190,10 +191,13 @@ public class DoricContext {
} }
public void teardown() { public void teardown() {
for (Animator animator : animators.values()) { Set<String> animatorIds = animators.keySet();
for (String animatorId : animatorIds) {
Animator animator = animators.remove(animatorId);
if (animator != null) {
animator.cancel(); animator.cancel();
} }
animators.clear(); }
callEntity(DoricConstant.DORIC_ENTITY_DESTROY).setCallback(new AsyncResult.Callback<JSDecoder>() { callEntity(DoricConstant.DORIC_ENTITY_DESTROY).setCallback(new AsyncResult.Callback<JSDecoder>() {
@Override @Override
public void onResult(JSDecoder result) { public void onResult(JSDecoder result) {