HarlonWang / AVLoadingIndicatorView

DEPRECATED
9.75k stars 1.9k forks source link

BallClipRotateIndicator leaks an Activity #56

Open martinvano opened 8 years ago

martinvano commented 8 years ago

2016-10-06 10 56 49 From the leak canary report it seems like BallClipRotateIndicator leaks a calling view (and activity afterward). It might be caused by keeping an implicit reference for calling postInvalidate(); method. Possible fix would be to clean up the reference in ondetachedfromwindow method.

Haoxiqiang commented 8 years ago

@martinvano I have the same problem.I solve it by add some code: BaseIndicatorController

 public void setAnimationStatus(AnimStatus animStatus) {
        if (mAnimators == null) {
            return;
        }
        int count = mAnimators.size();
        for (int i = 0; i < count; i++) {
            Animator animator = mAnimators.get(i);
            boolean isRunning = animator.isRunning();
            switch (animStatus) {
                case START:
                    if (!isRunning) {
                        animator.start();
                    }
                    break;
                case END:
                    if (isRunning) {
                        animator.end();
                    }
                    break;
                case CANCEL:
                    if (isRunning) {
                        animator.cancel();
                    }
                    if (animator instanceof ValueAnimator) {
                        ((ValueAnimator) animator).removeAllUpdateListeners();
                    }
                    animator.removeAllListeners();
                    break;
            }
        }
    }