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