示例#1
0
  private void startAnimation() {
    oldAction.flipHorizontally();
    currentAction.flipHorizontally();

    transformActions();

    animatedAction.setLineSegments(currentAction.getLineSegments());
    final ObjectAnimator animator =
        ObjectAnimator.ofFloat(ActionView.this, "animationProgress", 0f, 1f);
    animator.setInterpolator(BakedBezierInterpolator.getInstance());
    animator.setDuration(animationDuration).start();
  }
示例#2
0
  private void updatePath(Action action) {
    path.reset();

    final float[] data = action.getLineData();
    // Once we're near the end of the animation we use the action segments to draw linked lines
    if (animationProgress > 0.95f && !action.getLineSegments().isEmpty()) {
      for (LineSegment s : action.getLineSegments()) {
        path.moveTo(data[s.getStartIdx() + 0], data[s.getStartIdx() + 1]);
        path.lineTo(data[s.getStartIdx() + 2], data[s.getStartIdx() + 3]);
        for (int i = 1; i < s.indexes.length; i++) {
          path.lineTo(data[s.indexes[i] + 0], data[s.indexes[i] + 1]);
          path.lineTo(data[s.indexes[i] + 2], data[s.indexes[i] + 3]);
        }
      }
    } else {
      for (int i = 0; i < data.length; i += 4) {
        path.moveTo(data[i + 0], data[i + 1]);
        path.lineTo(data[i + 2], data[i + 3]);
      }
    }
  }