@NonNull public static <T> ObjectAnimator ofInt(@Nullable T target, @NonNull Property<T, Integer> xProperty, @NonNull Property<T, Integer> yProperty, @NonNull Path path) { int[] xValues = new int[NUM_POINTS]; int[] yValues = new int[NUM_POINTS]; calculateXYValues(path, xValues, yValues); PropertyValuesHolder xPvh = PropertyValuesHolder.ofInt(xProperty, xValues); PropertyValuesHolder yPvh = PropertyValuesHolder.ofInt(yProperty, yValues); return ObjectAnimator.ofPropertyValuesHolder(target, xPvh, yPvh); }
@NonNull public static ObjectAnimator ofInt(@Nullable Object target, @NonNull String xPropertyName, @NonNull String yPropertyName, @NonNull Path path) { int[] xValues = new int[NUM_POINTS]; int[] yValues = new int[NUM_POINTS]; calculateXYValues(path, xValues, yValues); PropertyValuesHolder xPvh = PropertyValuesHolder.ofInt(xPropertyName, xValues); PropertyValuesHolder yPvh = PropertyValuesHolder.ofInt(yPropertyName, yValues); return ObjectAnimator.ofPropertyValuesHolder(target, xPvh, yPvh); }
break; case MoveType.back: PropertyValuesHolder pvhX = PropertyValuesHolder.ofInt("x", mFloatView.getX(), mB.xOffset); PropertyValuesHolder pvhY = PropertyValuesHolder.ofInt("y", mFloatView.getY(), mB.yOffset); mAnimator = ObjectAnimator.ofPropertyValuesHolder(pvhX, pvhY); mAnimator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
break; case MoveType.back: PropertyValuesHolder pvhX = PropertyValuesHolder.ofInt("x", mFloatView.getX(), mB.xOffset); PropertyValuesHolder pvhY = PropertyValuesHolder.ofInt("y", mFloatView.getY(), mB.yOffset); mAnimator = ObjectAnimator.ofPropertyValuesHolder(pvhX, pvhY); mAnimator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
private PropertyValuesHolder createPropertyValuesHolder(String prop, float startValue, float endValue) { return PropertyValuesHolder.ofInt(prop, (int) startValue, (int) endValue); }
@Override protected ValueAnimator createAnimator(Drawer drawer) { return ObjectAnimator.ofPropertyValuesHolder(drawer, PropertyValuesHolder.ofInt("i", 0, 200)) .setDuration(20000); } });
@Override protected ValueAnimator createAnimator(Drawer drawer) { return ObjectAnimator.ofPropertyValuesHolder(drawer, PropertyValuesHolder.ofInt("i", 0, 200)) .setDuration(20000); } });
private PropertyValuesHolder createColorPropertyHolder(String propertyName, int startValue, int endValue) { PropertyValuesHolder holder = PropertyValuesHolder.ofInt(propertyName, startValue, endValue); holder.setEvaluator(new IntEvaluator()); return holder; }
public void startCircleMajor(final Callback callback) { PropertyValuesHolder rp = PropertyValuesHolder.ofFloat("radius", 0, circleMaxRadius); PropertyValuesHolder ap = PropertyValuesHolder.ofFloat("alpha", 1, 0); PropertyValuesHolder sp = PropertyValuesHolder.ofInt("stroke", (int) (circleMaxRadius * .15f), 0); ValueAnimator va = ValueAnimator.ofPropertyValuesHolder(rp, ap, sp); va.setInterpolator(new AccelerateInterpolator(.4f)); va.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() { @Override public void onAnimationUpdate(ValueAnimator animation) { circleRadius = (float) animation.getAnimatedValue("radius"); circleAlpha = (float) animation.getAnimatedValue("alpha"); circleStroke = (int) animation.getAnimatedValue("stroke"); callback.onValueUpdated(); } }); va.setDuration(450); va.start(); }
private PropertyValuesHolder createSlidePropertyHolder() { PropertyValuesHolder holder = PropertyValuesHolder.ofInt(ANIMATION_COORDINATE, coordinateStart, coordinateEnd); holder.setEvaluator(new IntEvaluator()); return holder; }
public void startCircleMinor(final Callback callback) { PropertyValuesHolder rp2 = PropertyValuesHolder.ofFloat("radius", 0, circleMaxRadius * .60f); PropertyValuesHolder ap2 = PropertyValuesHolder.ofFloat("alpha", 1, 0); PropertyValuesHolder sp2 = PropertyValuesHolder.ofInt("stroke", (int) (circleMaxRadius * .06f), 0); ValueAnimator va2 = ValueAnimator.ofPropertyValuesHolder(rp2, ap2, sp2); va2.setInterpolator(new AccelerateInterpolator(.4f)); va2.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() { @Override public void onAnimationUpdate(ValueAnimator animation) { circleRadius2 = (float) animation.getAnimatedValue("radius"); circleAlpha2 = (float) animation.getAnimatedValue("alpha"); circleStroke2 = (int) animation.getAnimatedValue("stroke"); callback.onValueUpdated(); } }); va2.setDuration(380); va2.start(); }
@NonNull private PropertyValuesHolder createStrokePropertyHolder(boolean isReverse) { String propertyName; int startStrokeValue; int endStrokeValue; if (isReverse) { propertyName = ANIMATION_STROKE_REVERSE; startStrokeValue = radius; endStrokeValue = 0; } else { propertyName = ANIMATION_STROKE; startStrokeValue = 0; endStrokeValue = radius; } PropertyValuesHolder holder = PropertyValuesHolder.ofInt(propertyName, startStrokeValue, endStrokeValue); holder.setEvaluator(new IntEvaluator()); return holder; }
@NonNull protected PropertyValuesHolder createScalePropertyHolder(boolean isReverse) { String propertyName; int startRadiusValue; int endRadiusValue; if (isReverse) { propertyName = ANIMATION_SCALE_REVERSE; startRadiusValue = radius; endRadiusValue = (int) (radius * scaleFactor); } else { propertyName = ANIMATION_SCALE; startRadiusValue = (int) (radius * scaleFactor); endRadiusValue = radius; } PropertyValuesHolder holder = PropertyValuesHolder.ofInt(propertyName, startRadiusValue, endRadiusValue); holder.setEvaluator(new IntEvaluator()); return holder; }
private void startProgressAnimation(double oldCurrentProgress, final double finalAngle) { final PropertyValuesHolder angleProperty = PropertyValuesHolder.ofInt(PROPERTY_ANGLE, sweepAngle, (int) finalAngle); progressAnimator = ValueAnimator.ofObject(new TypeEvaluator<Double>() { @Override public Double evaluate(float fraction, Double startValue, Double endValue) { return (startValue + (endValue - startValue) * fraction); } }, oldCurrentProgress, progressValue); progressAnimator.setDuration(DEFAULT_ANIMATION_DURATION); progressAnimator.setValues(angleProperty); progressAnimator.setInterpolator(new AccelerateDecelerateInterpolator()); progressAnimator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() { @Override public void onAnimationUpdate(ValueAnimator animation) { sweepAngle = (int) animation.getAnimatedValue(PROPERTY_ANGLE); invalidate(); } }); progressAnimator.addListener(new DefaultAnimatorListener() { @Override public void onAnimationCancel(Animator animation) { sweepAngle = (int) finalAngle; invalidate(); progressAnimator = null; } }); progressAnimator.start(); }
@NonNull private PropertyValuesHolder createRadiusPropertyHolder(boolean isReverse) { String propertyName; int startRadiusValue; int endRadiusValue; if (isReverse) { propertyName = ANIMATION_RADIUS_REVERSE; startRadiusValue = radius / 2; endRadiusValue = radius; } else { propertyName = ANIMATION_RADIUS; startRadiusValue = radius; endRadiusValue = radius / 2; } PropertyValuesHolder holder = PropertyValuesHolder.ofInt(propertyName, startRadiusValue, endRadiusValue); holder.setEvaluator(new IntEvaluator()); return holder; }
@NonNull @Override protected PropertyValuesHolder createScalePropertyHolder(boolean isReverse) { String propertyName; int startRadiusValue; int endRadiusValue; if (isReverse) { propertyName = ANIMATION_SCALE_REVERSE; startRadiusValue = (int) (radius * scaleFactor); endRadiusValue = radius; } else { propertyName = ANIMATION_SCALE; startRadiusValue = radius; endRadiusValue = (int) (radius * scaleFactor); } PropertyValuesHolder holder = PropertyValuesHolder.ofInt(propertyName, startRadiusValue, endRadiusValue); holder.setEvaluator(new IntEvaluator()); return holder; } }
PropertyValuesHolder createColorPropertyHolder(boolean isReverse) { String propertyName; int colorStart; int colorEnd; if (isReverse) { propertyName = ANIMATION_COLOR_REVERSE; colorStart = this.colorEnd; colorEnd = this.colorStart; } else { propertyName = ANIMATION_COLOR; colorStart = this.colorStart; colorEnd = this.colorEnd; } PropertyValuesHolder holder = PropertyValuesHolder.ofInt(propertyName, colorStart, colorEnd); holder.setEvaluator(new ArgbEvaluator()); return holder; }
@Deprecated private ValueAnimator createConvertAnimator(final View view) { int width = getWidth() - getPaddingLeft() - getPaddingRight() - 2 * mOutLinePadding; int height = getHeight() - getPaddingBottom() - getPaddingTop() - 2 * mOutLinePadding; PropertyValuesHolder left = PropertyValuesHolder.ofInt("left", view.getLeft(), getPaddingLeft() + mInnerPadding + mOutLinePadding); PropertyValuesHolder right = PropertyValuesHolder.ofInt("right", view.getRight(), getPaddingLeft() + mInnerPadding + mOutLinePadding + getItemWidth(width)); PropertyValuesHolder top = PropertyValuesHolder.ofInt("top", view.getTop(), getPaddingTop() + mInnerPadding + mOutLinePadding); PropertyValuesHolder bottom = PropertyValuesHolder.ofInt("bottom", view.getBottom(), getPaddingTop() + mInnerPadding + mOutLinePadding + getItemHeight(height)); ValueAnimator animator = ObjectAnimator.ofPropertyValuesHolder(left, right, top, bottom); animator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() { @Override public void onAnimationUpdate(ValueAnimator animation) { int left = (int) animation.getAnimatedValue("left"); int right = (int) animation.getAnimatedValue("right"); int top = (int) animation.getAnimatedValue("top"); int bottom = (int) animation.getAnimatedValue("bottom"); view.layout(left, top, right, bottom); } }); animator.setInterpolator(new DecelerateInterpolator()); return animator; }