matrix
matrix copied to clipboard
修复SwipeRefreshLayout空指针异常
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会比较好。
请问有可以复现的代码吗?可能在某些特殊情况下 Activity destroy 后重复回调了 onDetachedFromWindow,看看有没有除了加白之外的解法
请问有可以复现的代码吗?可能在某些特殊情况下 Activity destroy 后重复回调了
onDetachedFromWindow,看看有没有除了加白之外的解法
SwipeRefreshLayout#reset 一共有四个地方调用: onAnimationEnd onDetachedFromWindow setEnabled(false) 和 setProgressViewOffset,我只在后两者错误使用的情况下(destroy 之后调用)复现问题,但 issue #540 中反馈的在 onDetach 发生 NPE 的情况没有复现
偶然有复现,1.0.0給设置一个动画并执行,在detachwindow的时候就有几率复现,这里源码在处理的时候只是重置,没有置为空,应该也是有考虑动画原因吧
---原始邮件--- 发件人: @.> 发送时间: 2021年11月16日(周二) 晚上9:39 收件人: @.>; 抄送: @.@.>; 主题: Re: [Tencent/matrix] 修复SwipeRefreshLayout空指针异常 (PR #672)
请问有可以复现的代码吗?可能在某些特殊情况下 Activity destroy 后重复回调了 onDetachedFromWindow,看看有没有除了加白之外的解法
— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub, or unsubscribe. Triage notifications on the go with GitHub Mobile for iOS or Android.
偶尔复现,加了动画后activity销毁了。是不是gc不是立马生效,所以后续有一些回调刚好执行了Reset。而Reset的drawable被销毁了导致npe。重复调用detachwindow没有预订过,如有也麻烦大佬告知一下。 个人观点这种存在自定义处理过程的view最好加个白名单处理
---原始邮件--- 发件人: @.> 发送时间: 2021年11月16日(周二) 晚上9:43 收件人: @.>; 抄送: @.@.>; 主题: Re: [Tencent/matrix] 修复SwipeRefreshLayout空指针异常 (PR #672)
请问有可以复现的代码吗?可能在某些特殊情况下 Activity destroy 后重复回调了 onDetachedFromWindow,看看有没有除了加白之外的解法
SwipeRefreshLayout#reset 一共有四个地方调用: onAnimationEnd onDetachedFromWindow setEnabled(false) 和 setProgressViewOffset,我只在后两者错误使用的情况下(destroy 之后调用)复现问题,但 issue #540 中反馈的在 onDetach 发生 NPE 的情况没有复现
— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub, or unsubscribe. Triage notifications on the go with GitHub Mobile for iOS or Android.