android.animation.TypeEvaluator Java Examples
The following examples show how to use
android.animation.TypeEvaluator.
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: VerifyIdentityActivity.java From mollyim-android with GNU General Public License v3.0 | 6 votes |
private void setCodeSegment(final TextView codeView, String segment) { ValueAnimator valueAnimator = new ValueAnimator(); valueAnimator.setObjectValues(0, Integer.parseInt(segment)); valueAnimator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() { @Override public void onAnimationUpdate(ValueAnimator animation) { int value = (int) animation.getAnimatedValue(); codeView.setText(String.format(Locale.getDefault(), "%05d", value)); } }); valueAnimator.setEvaluator(new TypeEvaluator<Integer>() { public Integer evaluate(float fraction, Integer startValue, Integer endValue) { return Math.round(startValue + (endValue - startValue) * fraction); } }); valueAnimator.setDuration(1000); valueAnimator.start(); }
Example #2
Source File: AnimatorFactory.java From scene with Apache License 2.0 | 5 votes |
public AnimatorFactory(@NonNull T target, @NonNull Property<T, F> property, @NonNull TypeEvaluator<F> typeEvaluator, @NonNull F startValue, @NonNull F endValue, @Nullable TimeInterpolator interpolator) { this.mTarget = target; this.mTypeEvaluator = typeEvaluator; this.mProperty = property; this.mStartValue = startValue; this.mEndValue = endValue; this.mInterpolator = interpolator; }
Example #3
Source File: MarkerAnimation.java From osmdroid with Apache License 2.0 | 5 votes |
@TargetApi(Build.VERSION_CODES.ICE_CREAM_SANDWICH) public static ObjectAnimator animateMarkerToICS(final MapView map, Marker marker, GeoPoint finalPosition, final GeoPointInterpolator GeoPointInterpolator) { TypeEvaluator<GeoPoint> typeEvaluator = new TypeEvaluator<GeoPoint>() { @Override public GeoPoint evaluate(float fraction, GeoPoint startValue, GeoPoint endValue) { return GeoPointInterpolator.interpolate(fraction, startValue, endValue); } }; Property<Marker, GeoPoint> property = Property.of(Marker.class, GeoPoint.class, "position"); ObjectAnimator animator = ObjectAnimator.ofObject(marker, property, typeEvaluator, finalPosition); animator.setDuration(3000); animator.start(); return animator; }
Example #4
Source File: PathAnimatorInflater.java From ElasticProgressBar with Apache License 2.0 | 5 votes |
/** * Setup the Animator to achieve path morphing. * * @param anim The target Animator which will be updated. * @param arrayAnimator TypedArray for the ValueAnimator. * @return the PathDataEvaluator. */ private static TypeEvaluator setupAnimatorForPath(ValueAnimator anim, TypedArray arrayAnimator) { TypeEvaluator evaluator = null; String fromString = arrayAnimator.getString(R.styleable.Animator_vc_valueFrom); String toString = arrayAnimator.getString(R.styleable.Animator_vc_valueTo); PathParser.PathDataNode[] nodesFrom = PathParser.createNodesFromPathData(fromString); PathParser.PathDataNode[] nodesTo = PathParser.createNodesFromPathData(toString); if (nodesFrom != null) { if (nodesTo != null) { anim.setObjectValues(nodesFrom, nodesTo); if (!PathParser.canMorph(nodesFrom, nodesTo)) { throw new InflateException(arrayAnimator.getPositionDescription() + " Can't morph from " + fromString + " to " + toString); } } else { anim.setObjectValues((Object) nodesFrom); } evaluator = new PathDataEvaluator(PathParser.deepCopyNodes(nodesFrom)); } else if (nodesTo != null) { anim.setObjectValues((Object) nodesTo); evaluator = new PathDataEvaluator(PathParser.deepCopyNodes(nodesTo)); } if (DBG_ANIMATOR_INFLATER && evaluator != null) { Log.v(LOG_TAG, "create a new PathDataEvaluator here"); } return evaluator; }
Example #5
Source File: PathAnimatorInflater.java From ElasticProgressBar with Apache License 2.0 | 5 votes |
/** * @param anim The animator, must not be null * @param arrayAnimator Incoming typed array for Animator's attributes. * @param arrayObjectAnimator Incoming typed array for Object Animator's * attributes. */ private static void parseAnimatorFromTypeArray(ValueAnimator anim, TypedArray arrayAnimator, TypedArray arrayObjectAnimator) { long duration = arrayAnimator.getInt(R.styleable.Animator_android_duration, 300); long startDelay = arrayAnimator.getInt(R.styleable.Animator_android_startOffset, 0); int valueType = arrayAnimator.getInt(R.styleable.Animator_vc_valueType, 0); TypeEvaluator evaluator = null; // Must be a path animator by the time I reach here if (valueType == VALUE_TYPE_PATH) { evaluator = setupAnimatorForPath(anim, arrayAnimator); } else { throw new IllegalArgumentException("target is not a pathType target"); } anim.setDuration(duration); anim.setStartDelay(startDelay); if (arrayAnimator.hasValue(R.styleable.Animator_android_repeatCount)) { anim.setRepeatCount( arrayAnimator.getInt(R.styleable.Animator_android_repeatCount, 0)); } if (arrayAnimator.hasValue(R.styleable.Animator_android_repeatMode)) { anim.setRepeatMode( arrayAnimator.getInt(R.styleable.Animator_android_repeatMode, ValueAnimator.RESTART)); } if (evaluator != null) { anim.setEvaluator(evaluator); } if (arrayObjectAnimator != null) { setupObjectAnimator(anim, arrayObjectAnimator); } }
Example #6
Source File: FloatingActionButtonImpl.java From material-components-android with Apache License 2.0 | 5 votes |
/** * There appears to be a bug in the OpenGL shadow rendering code on API 26. We can work around it * by preventing any scaling close to 0. */ private void workAroundOreoBug(final ObjectAnimator animator) { if (Build.VERSION.SDK_INT != Build.VERSION_CODES.O) { return; } animator.setEvaluator(new TypeEvaluator<Float>() { FloatEvaluator floatEvaluator = new FloatEvaluator(); @Override public Float evaluate(float fraction, Float startValue, Float endValue) { float evaluated = floatEvaluator.evaluate(fraction, startValue, endValue); return evaluated < 0.1f ? 0.0f : evaluated; } }); }
Example #7
Source File: ReflowTextAnimatorHelper.java From reflow-animator with Apache License 2.0 | 5 votes |
@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; }
Example #8
Source File: ViewUtils.java From MaterialStepperView with MIT License | 5 votes |
static ObjectAnimator createArgbAnimator(View view, String propertyName, int startColor, int endColor) { if (Build.VERSION.SDK_INT < Build.VERSION_CODES.LOLLIPOP) { return ObjectAnimator.ofObject(view, propertyName, new TypeEvaluator() { @Override public Object evaluate(float fraction, Object startValue, Object endValue) { int startInt = (Integer) startValue; int startA = (startInt >> 24) & 0xff; int startR = (startInt >> 16) & 0xff; int startG = (startInt >> 8) & 0xff; int startB = startInt & 0xff; int endInt = (Integer) endValue; int endA = (endInt >> 24) & 0xff; int endR = (endInt >> 16) & 0xff; int endG = (endInt >> 8) & 0xff; int endB = endInt & 0xff; return (startA + (int)(fraction * (endA - startA))) << 24 | (startR + (int)(fraction * (endR - startR))) << 16 | (startG + (int)(fraction * (endG - startG))) << 8 | (startB + (int)(fraction * (endB - startB))); } }, startColor, endColor); } else { return ObjectAnimator.ofArgb(view, propertyName, startColor, endColor); } }
Example #9
Source File: AdditiveAnimation.java From android_additive_animations with Apache License 2.0 | 4 votes |
public void setCustomTypeEvaluator(TypeEvaluator<Float> evaluator) { mCustomTypeEvaluator = evaluator; }
Example #10
Source File: AdditiveAnimation.java From android_additive_animations with Apache License 2.0 | 4 votes |
public TypeEvaluator getCustomTypeEvaluator() { return mCustomTypeEvaluator; }
Example #11
Source File: SingleAnimationAction.java From android_additive_animations with Apache License 2.0 | 4 votes |
public SingleAnimationAction(Property<T, Float> property, float target, TypeEvaluator<Float> evaluator) { mAnimations.add(new AnimationAction.Animation<T>(property, target, evaluator)); }
Example #12
Source File: AnimationAction.java From android_additive_animations with Apache License 2.0 | 4 votes |
public Animation(Property<T, Float> property, float targetValue, TypeEvaluator<Float> evaluator) { this.mProperty = property; this.mTargetValue = targetValue; this.mTypeEvaluator = evaluator; }
Example #13
Source File: AnimationAction.java From android_additive_animations with Apache License 2.0 | 4 votes |
public TypeEvaluator<Float> getTypeEvaluator() { return mTypeEvaluator; }
Example #14
Source File: BaseAdditiveAnimator.java From android_additive_animations with Apache License 2.0 | 4 votes |
protected final AdditiveAnimation createAnimation(Property<V, Float> property, float targetValue, TypeEvaluator<Float> evaluator) { AdditiveAnimation animation = new AdditiveAnimation<>(mCurrentTarget, property, property.get(mCurrentTarget), targetValue); animation.setCustomTypeEvaluator(evaluator); animation.setCustomInterpolator(mCurrentCustomInterpolator); return animation; }
Example #15
Source File: BaseAdditiveAnimator.java From android_additive_animations with Apache License 2.0 | 4 votes |
protected final T animate(Property<V, Float> property, float target, TypeEvaluator<Float> evaluator) { initValueAnimatorIfNeeded(); AdditiveAnimation animation = createAnimation(property, target, evaluator); return animate(animation); }
Example #16
Source File: RxAnimator.java From RxAnimator with Apache License 2.0 | 4 votes |
public RxAnimatorObservable animationEvaluator(TypeEvaluator evaluator) { this.evaluator = evaluator; return this; }
Example #17
Source File: SimpleMenuAnimation.java From MaterialPreference with Apache License 2.0 | 4 votes |
@SuppressWarnings("unchecked") private static Animator createElevationAnimator(View view, float elevation) { Animator animator = ObjectAnimator.ofObject(view, View.TRANSLATION_Z, (TypeEvaluator) new FloatEvaluator(), -elevation, 0f); animator.setInterpolator(new FastOutSlowInInterpolator()); return animator; }
Example #18
Source File: AnimatorValueImplements.java From TikTok with Apache License 2.0 | 4 votes |
public ObjectAnimator createProNameObject(Object object,TypeEvaluator<Object> typeEvaluator, String proName, Object... values) { objectAnimator=ObjectAnimator.ofObject(object, proName, typeEvaluator, values); return objectAnimator; }
Example #19
Source File: AnimatorValueImplements.java From TikTok with Apache License 2.0 | 4 votes |
public AnimatorValueImplements(Object object, TypeEvaluator<Object> typeEvaluator, String proName, Object... values){ createProNameObject(object, typeEvaluator, proName, values); }
Example #20
Source File: ChangeImageTransform.java From Transitions-Everywhere with Apache License 2.0 | 4 votes |
private ObjectAnimator createMatrixAnimator(ImageView imageView, TypeEvaluator<Matrix> evaluator, Matrix startMatrix, final Matrix endMatrix) { return ObjectAnimator.ofObject(imageView, ANIMATED_TRANSFORM_PROPERTY, evaluator, startMatrix, endMatrix); }
Example #21
Source File: Holder.java From scene with Apache License 2.0 | 4 votes |
public Holder(TypeEvaluator typeEvaluator, Object fromValue, Object toValue) { this.typeEvaluator = typeEvaluator; this.fromValue = fromValue; this.toValue = toValue; }
Example #22
Source File: BaseAdditiveAnimator.java From android_additive_animations with Apache License 2.0 | 2 votes |
/** * Old API for {@link #property(float, TypeEvaluator, FloatProperty)}, which should be used instead. * * @deprecated Use {@link #property(float, TypeEvaluator, FloatProperty)} instead. */ public T animateProperty(float target, TypeEvaluator<Float> evaluator, FloatProperty<V> property) { return property(target, evaluator, property); }