com.robinhood.spark.SparkView Java Examples

The following examples show how to use com.robinhood.spark.SparkView. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: LineSparkAnimator.java    From spark with Apache License 2.0 5 votes vote down vote up
@Nullable
@Override
public Animator getAnimation(final SparkView sparkView) {
    final Path linePath = sparkView.getSparkLinePath();

    // get path length
    final PathMeasure pathMeasure = new PathMeasure(linePath, false);
    final float endLength = pathMeasure.getLength();

    if (endLength <= 0) {
        return null;
    }

    animator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
        @Override
        public void onAnimationUpdate(ValueAnimator animation) {
            float animatedValue = (float) animation.getAnimatedValue();

            float animatedPathLength = animatedValue * endLength;

            linePath.reset();
            pathMeasure.getSegment(0, animatedPathLength, linePath, true);

            // set the updated path for the animation
            sparkView.setAnimationPath(linePath);
        }
    });

    return animator;
}
 
Example #2
Source File: SparkAnimator.java    From spark with Apache License 2.0 2 votes vote down vote up
/**
 * Returns an Animator that performs the desired animation. Must call
 * {@link SparkView#setAnimationPath} for each animation frame.
 *
 * See {@link LineSparkAnimator} and {@link MorphSparkAnimator} for examples.
 *
 * @param sparkView The SparkView object
 */
@Nullable
Animator getAnimation(final SparkView sparkView);