in app/src/main/java/com/google/reviewit/SortChangesFragment.java [402:468]
private void animate(
final View changeBox, final SortActionHandler.Action action) {
final ViewGroup resultBox = vg(R.id.resultBox);
Point screenSize = getScreenSize();
final int screenCenter = screenSize.x / 2;
ObjectAnimator animator;
switch (action) {
case STAR:
animator = ObjectAnimator.ofFloat(changeBox, "x", screenSize.x);
break;
case IGNORE:
animator = ObjectAnimator.ofFloat(changeBox, "x",
-changeBox.getWidth());
break;
case SKIP:
animator = ObjectAnimator.ofFloat(changeBox, "alpha", 0);
break;
case NONE:
return;
default:
throw new IllegalStateException("unknown action: " + action);
}
animator.setDuration(1000);
animator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
@Override
public void onAnimationUpdate(ValueAnimator animation) {
switch (action) {
case STAR:
changeBox.setRotation((float) (
(changeBox.getX() + changeBox.getWidth() / 2 - screenCenter)
* (Math.PI / 32)));
((GradientDrawable) changeBox.getBackground())
.setColor(widgetUtil.color(R.color.commitMessageStar));
break;
case IGNORE:
changeBox.setRotation(
(float) ((changeBox.getX() +
changeBox.getWidth() / 2 - screenCenter)
* (Math.PI / 32)));
((GradientDrawable) changeBox.getBackground())
.setColor(widgetUtil.color(R.color.commitMessageIgnore));
break;
case SKIP:
case NONE:
default:
break;
}
}
});
animator.addListener(new NoOpAnimatorListener() {
@Override
public void onAnimationEnd(Animator animation) {
switch (action) {
case STAR:
case IGNORE:
case SKIP:
resultBox.removeView(changeBox);
display();
case NONE:
default:
break;
}
}
});
animator.start();
}