fix somebug of defaultitemanimator&viewinfostore

This commit is contained in:
侯歌 2024-07-06 15:53:41 +08:00
parent decdfdacbf
commit 512e066a15
3 changed files with 6 additions and 6 deletions

View File

@ -284,13 +284,14 @@ void DefaultItemAnimator::onChangeAnimationEnd(bool old,ChangeInfo*changeInfo,An
View*view = holder == nullptr ? nullptr : holder->itemView;
if(view&&holder){
ViewPropertyAnimator& animator = view->animate();
animator.setListener({});
animator.setListener({});
view->setAlpha(1);
view->setTranslationX(0);
view->setTranslationY(0);
dispatchChangeFinished(*holder, old);
auto it = std::find(mChangeAnimations.begin(),mChangeAnimations.end(),holder);
mChangeAnimations.erase(it);//remove(*changeInfo.oldHolder);
if(it!=mChangeAnimations.end())
mChangeAnimations.erase(it);
dispatchFinishedWhenDone();
}
@ -438,7 +439,7 @@ void DefaultItemAnimator::endAnimation(RecyclerView::ViewHolder& item) {
//noinspection PointlessBooleanExpression,ConstantConditions
itItem = std::find(mAddAnimations.begin(),mAddAnimations.end(),&item);
if ( it!=mAddAnimations.end() ) {
if ( itItem!=mAddAnimations.end() ) {
mAddAnimations.erase(itItem);
LOGE_IF(_DEBUG,"after animation is cancelled, item should not be in mAddAnimations list");
}
@ -452,7 +453,7 @@ void DefaultItemAnimator::endAnimation(RecyclerView::ViewHolder& item) {
//noinspection PointlessBooleanExpression,ConstantConditions
itItem = std::find(mMoveAnimations.begin(),mMoveAnimations.end(),&item);
if ( it!=mMoveAnimations.end() ) {
if ( itItem!=mMoveAnimations.end() ) {
mMoveAnimations.erase(itItem);
LOGE_IF(_DEBUG,"after animation is cancelled, item should not be in mMoveAnimations list");
}

View File

@ -2524,7 +2524,6 @@ void RecyclerView::dispatchLayoutStep3() {
mViewInfoStore->addToPostLayout(holder, &animationInfo);
} else {
ItemAnimator::ItemHolderInfo* preInfo = mViewInfoStore->popFromPreLayout(oldChangeViewHolder);
mViewInfoStore->popFromPreLayout(holder);//added by chenyang
// we add and remove so that any post info is merged.
mViewInfoStore->addToPostLayout(holder, &animationInfo);
ItemAnimator::ItemHolderInfo* postInfo = mViewInfoStore->popFromPostLayout(holder);

View File

@ -162,7 +162,7 @@ void ViewInfoStore::process(ProcessCallback callback) {
}
void ViewInfoStore::removeViewHolder(RecyclerView::ViewHolder* holder) {
for (int i =mOldChangedHolders.size()-1;i>=0;i++){
for (int i = mOldChangedHolders.size()-1;i>=0;i--){
if (holder == mOldChangedHolders.valueAt(i)) {
mOldChangedHolders.removeAt(i);
break;