Move shared end pending anim logic for reusability

Some of the logic in endAnimations and endAnimation is shared and should
be moved to a common helper method.

Test: Builds and functions as before
Change-Id: I4973d50ad8778bb397938b5d65d9f95f48ff145b
This commit is contained in:
Kevin 2019-05-09 17:32:11 -07:00
parent f079b277cf
commit b0fcded7aa
1 changed files with 17 additions and 26 deletions

View File

@ -216,20 +216,8 @@ public final class ContentFillItemAnimator extends SimpleItemAnimator {
@Override
public void endAnimation(@NonNull ViewHolder item) {
for (int i = mPendingAnims.size() - 1; i >= 0; i--) {
PendingAnimation pendAnim = mPendingAnims.get(i);
if (pendAnim.viewHolder == item) {
mPendingAnims.remove(i);
switch (pendAnim.animType) {
case ANIM_TYPE_REMOVE:
dispatchRemoveFinished(item);
break;
case ANIM_TYPE_CHANGE:
dispatchChangeFinished(item, true /* oldItem */);
break;
default:
break;
}
}
endPendingAnimation(mPendingAnims.get(i));
mPendingAnims.remove(i);
}
dispatchFinishedWhenDone();
}
@ -237,18 +225,7 @@ public final class ContentFillItemAnimator extends SimpleItemAnimator {
@Override
public void endAnimations() {
for (int i = mPendingAnims.size() - 1; i >= 0; i--) {
PendingAnimation pendAnim = mPendingAnims.get(i);
ViewHolder item = pendAnim.viewHolder;
switch (pendAnim.animType) {
case ANIM_TYPE_REMOVE:
dispatchRemoveFinished(item);
break;
case ANIM_TYPE_CHANGE:
dispatchChangeFinished(item, true /* oldItem */);
break;
default:
break;
}
endPendingAnimation(mPendingAnims.get(i));
mPendingAnims.remove(i);
}
for (int i = mRunningAnims.size() - 1; i >= 0; i--) {
@ -259,6 +236,20 @@ public final class ContentFillItemAnimator extends SimpleItemAnimator {
dispatchAnimationsFinished();
}
private void endPendingAnimation(PendingAnimation pendAnim) {
ViewHolder item = pendAnim.viewHolder;
switch (pendAnim.animType) {
case ANIM_TYPE_REMOVE:
dispatchRemoveFinished(item);
break;
case ANIM_TYPE_CHANGE:
dispatchChangeFinished(item, true /* oldItem */);
break;
default:
break;
}
}
@Override
public boolean isRunning() {
return !mPendingAnims.isEmpty() || !mRunningAnims.isEmpty();