|
|
@ -22,7 +22,10 @@ import android.support.v4.view.ViewPropertyAnimatorListener; |
|
|
|
import android.support.v7.widget.RecyclerView; |
|
|
|
import android.support.v7.widget.RecyclerView; |
|
|
|
import android.support.v7.widget.RecyclerView.ViewHolder; |
|
|
|
import android.support.v7.widget.RecyclerView.ViewHolder; |
|
|
|
import android.support.v7.widget.SimpleItemAnimator; |
|
|
|
import android.support.v7.widget.SimpleItemAnimator; |
|
|
|
|
|
|
|
import android.util.Log; |
|
|
|
import android.view.View; |
|
|
|
import android.view.View; |
|
|
|
|
|
|
|
import android.view.animation.AccelerateInterpolator; |
|
|
|
|
|
|
|
import android.view.animation.DecelerateInterpolator; |
|
|
|
|
|
|
|
|
|
|
|
import java.util.ArrayList; |
|
|
|
import java.util.ArrayList; |
|
|
|
import java.util.List; |
|
|
|
import java.util.List; |
|
|
@ -197,7 +200,8 @@ public class HorizontalItemAnimator extends SimpleItemAnimator { |
|
|
|
final ViewPropertyAnimatorCompat animation = ViewCompat.animate(view); |
|
|
|
final ViewPropertyAnimatorCompat animation = ViewCompat.animate(view); |
|
|
|
mRemoveAnimations.add(holder); |
|
|
|
mRemoveAnimations.add(holder); |
|
|
|
animation.setDuration(getRemoveDuration()) |
|
|
|
animation.setDuration(getRemoveDuration()) |
|
|
|
.alpha(0).translationY(holder.itemView.getHeight()).setListener(new VpaListenerAdapter() { |
|
|
|
.alpha(0).translationY(holder.itemView.getHeight()) |
|
|
|
|
|
|
|
.setInterpolator(new AccelerateInterpolator()).setListener(new VpaListenerAdapter() { |
|
|
|
@Override |
|
|
|
@Override |
|
|
|
public void onAnimationStart(View view) { |
|
|
|
public void onAnimationStart(View view) { |
|
|
|
dispatchRemoveStarting(holder); |
|
|
|
dispatchRemoveStarting(holder); |
|
|
@ -207,6 +211,7 @@ public class HorizontalItemAnimator extends SimpleItemAnimator { |
|
|
|
public void onAnimationEnd(View view) { |
|
|
|
public void onAnimationEnd(View view) { |
|
|
|
animation.setListener(null); |
|
|
|
animation.setListener(null); |
|
|
|
ViewCompat.setAlpha(view, 1); |
|
|
|
ViewCompat.setAlpha(view, 1); |
|
|
|
|
|
|
|
ViewCompat.setTranslationY(view, 0); |
|
|
|
dispatchRemoveFinished(holder); |
|
|
|
dispatchRemoveFinished(holder); |
|
|
|
mRemoveAnimations.remove(holder); |
|
|
|
mRemoveAnimations.remove(holder); |
|
|
|
dispatchFinishedWhenDone(); |
|
|
|
dispatchFinishedWhenDone(); |
|
|
@ -227,8 +232,9 @@ public class HorizontalItemAnimator extends SimpleItemAnimator { |
|
|
|
final View view = holder.itemView; |
|
|
|
final View view = holder.itemView; |
|
|
|
final ViewPropertyAnimatorCompat animation = ViewCompat.animate(view); |
|
|
|
final ViewPropertyAnimatorCompat animation = ViewCompat.animate(view); |
|
|
|
mAddAnimations.add(holder); |
|
|
|
mAddAnimations.add(holder); |
|
|
|
animation.alpha(1).translationY(0).setDuration(getAddDuration()). |
|
|
|
animation.alpha(1).translationY(0) |
|
|
|
setListener(new VpaListenerAdapter() { |
|
|
|
.setInterpolator(new DecelerateInterpolator()).setDuration(getAddDuration()) |
|
|
|
|
|
|
|
.setListener(new VpaListenerAdapter() { |
|
|
|
@Override |
|
|
|
@Override |
|
|
|
public void onAnimationStart(View view) { |
|
|
|
public void onAnimationStart(View view) { |
|
|
|
dispatchAddStarting(holder); |
|
|
|
dispatchAddStarting(holder); |
|
|
@ -236,6 +242,7 @@ public class HorizontalItemAnimator extends SimpleItemAnimator { |
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
@Override |
|
|
|
public void onAnimationCancel(View view) { |
|
|
|
public void onAnimationCancel(View view) { |
|
|
|
|
|
|
|
ViewCompat.setTranslationY(view, 0); |
|
|
|
ViewCompat.setAlpha(view, 1); |
|
|
|
ViewCompat.setAlpha(view, 1); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
@ -316,6 +323,17 @@ public class HorizontalItemAnimator extends SimpleItemAnimator { |
|
|
|
@Override |
|
|
|
@Override |
|
|
|
public boolean animateChange(ViewHolder oldHolder, ViewHolder newHolder, |
|
|
|
public boolean animateChange(ViewHolder oldHolder, ViewHolder newHolder, |
|
|
|
int fromX, int fromY, int toX, int toY) { |
|
|
|
int fromX, int fromY, int toX, int toY) { |
|
|
|
|
|
|
|
// if (oldHolder != newHolder) {
|
|
|
|
|
|
|
|
// if (oldHolder != null) {
|
|
|
|
|
|
|
|
// dispatchChangeFinished(oldHolder, true);
|
|
|
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
// if (newHolder != null) {
|
|
|
|
|
|
|
|
// dispatchChangeFinished(newHolder, false);
|
|
|
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
// } else if (oldHolder != null) {
|
|
|
|
|
|
|
|
// dispatchChangeFinished(oldHolder, true);
|
|
|
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
// return false;
|
|
|
|
if (oldHolder == newHolder) { |
|
|
|
if (oldHolder == newHolder) { |
|
|
|
// Don't know how to run change animations when the same view holder is re-used.
|
|
|
|
// Don't know how to run change animations when the same view holder is re-used.
|
|
|
|
// run a move animation to handle position changes.
|
|
|
|
// run a move animation to handle position changes.
|
|
|
|