am 3e56fbf0: am 3d7f086f: Merge "Prevent memory leaks coming from LauncherAnimUtils" into jb-ub-now-jetsonic

* commit '3e56fbf0017143811c74b8db64f0ce0453244532':
  Prevent memory leaks coming from LauncherAnimUtils
This commit is contained in:
Michael Jurka
2014-02-14 20:37:14 +00:00
committed by Android Git Automerger
@@ -25,12 +25,13 @@ import android.view.View;
import android.view.ViewTreeObserver; import android.view.ViewTreeObserver;
import java.util.HashSet; import java.util.HashSet;
import java.util.WeakHashMap;
public class LauncherAnimUtils { public class LauncherAnimUtils {
static HashSet<Animator> sAnimators = new HashSet<Animator>(); static WeakHashMap<Animator, Object> sAnimators = new WeakHashMap<Animator, Object>();
static Animator.AnimatorListener sEndAnimListener = new Animator.AnimatorListener() { static Animator.AnimatorListener sEndAnimListener = new Animator.AnimatorListener() {
public void onAnimationStart(Animator animation) { public void onAnimationStart(Animator animation) {
sAnimators.add(animation); sAnimators.put(animation, null);
} }
public void onAnimationRepeat(Animator animation) { public void onAnimationRepeat(Animator animation) {
@@ -74,13 +75,12 @@ public class LauncherAnimUtils {
} }
public static void onDestroyActivity() { public static void onDestroyActivity() {
HashSet<Animator> animators = new HashSet<Animator>(sAnimators); HashSet<Animator> animators = new HashSet<Animator>(sAnimators.keySet());
for (Animator a : animators) { for (Animator a : animators) {
if (a.isRunning()) { if (a.isRunning()) {
a.cancel(); a.cancel();
} else {
sAnimators.remove(a);
} }
sAnimators.remove(a);
} }
} }