Java 类android.transition.PathMotion 实例源码

项目:FunWithAndroid    文件:WelcomeFragmentStep1.java   
@TargetApi(Build.VERSION_CODES.LOLLIPOP)
private ChangeBounds getNextButtonTransition() {
    ChangeBounds arcMoveTransition = new ChangeBounds();
    //create "zorro" like path
    arcMoveTransition.setPathMotion(new PathMotion() {
        @Override
        public Path getPath(float startX, float startY, float endX, float endY) {
            Path p = new Path();
            p.moveTo(startX, startY);
            p.lineTo(endX, startY);
            p.lineTo(startX, endY);
            p.lineTo(endX, endY);
            return p;
        }
    });
    arcMoveTransition.setDuration(500);
    arcMoveTransition.setInterpolator(new AccelerateDecelerateInterpolator());
    return arcMoveTransition;
}
项目:reflow-animator    文件:ReflowTextAnimatorHelper.java   
@TargetApi(LOLLIPOP)
private PropertyValuesHolder getPathValuesHolder(Run run, int dy, int dx) {
    PropertyValuesHolder propertyValuesHolder;
    if (IS_LOLLIPOP_OR_ABOVE) {
        PathMotion pathMotion = new PathMotion() {
            @Override
            public Path getPath(float startX, float startY, float endX, float endY) {
                return ReflowTextAnimatorHelper.getPath(startX, startY, endX, endY);
            }
        };
        propertyValuesHolder = PropertyValuesHolder.ofObject(SwitchDrawable.TOP_LEFT, null,
                pathMotion.getPath(
                        run.getStart().left,
                        run.getStart().top,
                        run.getEnd().left - dx,
                        run.getEnd().top - dy));
    } else {
        PointF startPoint = new PointF(run.getStart().left, run.getStart().top);
        PointF endPoint = new PointF(run.getEnd().left - dx, run.getEnd().top - dy);
        propertyValuesHolder = PropertyValuesHolder.ofObject(SwitchDrawable.TOP_LEFT, new TypeEvaluator<PointF>() {
            private final PointF point = new PointF();

            @Override
            public PointF evaluate(float fraction, PointF startValue, PointF endValue) {
                float x = startValue.x + (endValue.x - startValue.x) * fraction;
                float y = startValue.y + (endValue.y - startValue.y) * fraction;

                point.set(x, y);

                return point;
            }
        }, startPoint, endPoint);
    }

    return propertyValuesHolder;
}