// RecyclerView的内部类
public static class State {
......
boolean mInPreLayout = false;
public boolean isPreLayout() {
return mInPreLayout;
}
......
}
第一处发生在 onMeasure()
if (this.mState.mRunPredictiveAnimations) {
this.mState.mInPreLayout = true;
} else {
this.mAdapterHelper.consumeUpdatesInOnePass();
this.mState.mInPreLayout = false;
}
第二处发生在 onLayout() -> dispatchLayout() -> dispatchLayoutStep1()
mState.mInPreLayout = mState.mRunPredictiveAnimations;
上述两处都和 mRunPredictiveAnimations 挂钩,所以我们需要找到 mRunPredictiveAnimations 被赋值为 true 的时候
// processAdapterUpdatesAndSetAnimationFlags() 有如下代码:
mState.mRunSimpleAnimations = mFirstLayoutComplete
&& mItemAnimator != null
&& (mDataSetHasChangedAfterLayout
|| animationTypeSupported
|| mLayout.mRequestedSimpleAnimations)
&& (!mDataSetHasChangedAfterLayout
|| mAdapter.hasStableIds());
mState.mRunPredictiveAnimations = mState.mRunSimpleAnimations
&& animationTypeSupported
&& !mDataSetHasChangedAfterLayout
&& predictiveItemAnimationsEnabled();
继续追溯 mRunSimpleAnimations,再追溯 mFirstLayoutComplete
@Override
protected void onLayout(boolean changed, int l, int t, int r, int b) {
TraceCompat.beginSection(TRACE_ON_LAYOUT_TAG);
dispatchLayout();
TraceCompat.endSection();
mFirstLayoutComplete = true;
}
原创声明:本文系作者授权腾讯云开发者社区发表,未经许可,不得转载。
如有侵权,请联系 cloudcommunity@tencent.com 删除。
原创声明:本文系作者授权腾讯云开发者社区发表,未经许可,不得转载。
如有侵权,请联系 cloudcommunity@tencent.com 删除。