Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

修复SwipeRefreshLayout空指针异常 #670

Conversation

TestPlanB
Copy link

fix #541
SwipeRefreshLayout 的reset方法在onDetachedFromWindow和mRefreshListener的onAnimationEnd都会调用,
void reset() {
mCircleView.clearAnimation();
mProgress.stop();
mCircleView.setVisibility(View.GONE);
setColorViewAlpha(MAX_ALPHA);
// Return the circle to its start position
if (mScale) {
setAnimationProgress(0 /* animation complete and view is hidden */);
} else {
setTargetOffsetTopAndBottom(mOriginalOffsetTop - mCurrentTargetOffsetTop);
}
mCurrentTargetOffsetTop = mCircleView.getTop();
}

mCircleView.clearAnimation后会回调onAnimationEnd,所以可能出现一种情况在onDetachedFromWindow后回调了监听器或者其他过程调用reset,里面都用到的了setAlpha,如果ActivityLeakFixer清除drawable资源就会导致外部的SwipeRefreshLayout调用出现异常。
SwipeRefreshLayout 这个库只是更多时候希望重置drawable,没有想要设置为null,因此ActivityLeakFixer忽略跳过删除drawable会比较好。

@TestPlanB TestPlanB closed this Nov 16, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants