Java Code Examples for android.animation.ObjectAnimator#ofObject()

The following examples show how to use android.animation.ObjectAnimator#ofObject() . 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: TriggerPoint2Activity.java    From ActionAnimatorSet with GNU General Public License v3.0 6 votes vote down vote up
private void initAnim(View v) {
    manager = new DefaultAnimatorManager();
    animSet = manager.createAnimatorSet();

    AnimPoint startPoint = AnimPoint.newInstance(0, 0);
    AnimPoint endPoint = cubicTo(0, 0, 0.86f, 0, -centerP.x, -centerP.y);
    ObjectAnimator anim1 = ObjectAnimator.ofObject(this,
            "Anim", new AnimEvaluator(), startPoint, endPoint);
    ObjectAnimator anim2 = ObjectAnimator.ofFloat(v, "scaleX", 1, 20);
    ObjectAnimator anim3 = ObjectAnimator.ofFloat(v, "scaleY", 1, 20);

    animSet.playFirst(anim1);
    animSet.addAnimBetween(anim2, anim1, new TriggerPoint<AnimPoint>() {
        @Override
        public boolean whenToStart(AnimPoint pointV) {
            return pointV.mEndX < -centerP.x + 100;//自定义何时开始anim2动画,此方法返回true时,anim2开始执行
        }
    });
    animSet.addAnimWith(anim3, anim2);//anim3和anim2同时执行
    animSet.setDuration(ANIM_TIME);

    animSet.start();
}
 
Example 2
Source File: PathAnimation.java    From XDroidAnimation with Apache License 2.0 6 votes vote down vote up
@Override
public AnimatorSet createAnimatorSet() {
	ViewHelper.setClipChildren(targetView, false);

	if (path == null) {
		throw new IllegalArgumentException("You have to set up a AnimatorPath for PathAnimation!");
	}

	ObjectAnimator anim = ObjectAnimator.ofObject(this, "ViewLoc", new PathEvaluator(), path.getPoints().toArray());
	AnimatorSet animatorSet = new AnimatorSet();
	animatorSet.play(anim);
	animatorSet.setDuration(duration);
	animatorSet.setInterpolator(interpolator);
	if (listener != null) {
		animatorSet.addListener(listener);
	}

	return animatorSet;
}
 
Example 3
Source File: EnterScreenAnimations.java    From YCGallery with Apache License 2.0 6 votes vote down vote up
/**
 * This method creates Animator that will animate matrix of ImageView.
 * It is needed in order to show the effect when scaling of one view is smoothly changed to the scale of the second view.
 * <p>
 * For example: first view can have scaleType: centerCrop, and the other one fitCenter.
 * The image inside ImageView will smoothly change from one to another
 */
private ObjectAnimator createEnteringImageMatrixAnimator() {

    Matrix initMatrix = MatrixUtils.getImageMatrix(mAnimatedImage);
    // store the data about original matrix into array.
    // this array will be used later for exit animation
    initMatrix.getValues(mInitThumbnailMatrixValues);

    final Matrix endMatrix = new Matrix(mImageTo.getMatrix());
    Log.v(TAG, "createEnteringImageMatrixAnimator, mInitThumbnailMatrixValues " + Arrays.toString(mInitThumbnailMatrixValues));

    Log.v(TAG, "createEnteringImageMatrixAnimator, initMatrix " + initMatrix);
    Log.v(TAG, "createEnteringImageMatrixAnimator,  endMatrix " + endMatrix);

    mAnimatedImage.setScaleType(ImageView.ScaleType.MATRIX);

    return ObjectAnimator.ofObject(mAnimatedImage, MatrixEvaluator.ANIMATED_TRANSFORM_PROPERTY,
            new MatrixEvaluator(), initMatrix, endMatrix);
}
 
Example 4
Source File: PointView.java    From AndroidDemo with Apache License 2.0 6 votes vote down vote up
private void startAnimation() {
	Point startPoint = new Point(RADIUS, RADIUS);
	Point endPoint = new Point(getWidth() - RADIUS, getHeight() - RADIUS);
	ValueAnimator anim = ValueAnimator.ofObject(new PointEvaluator(), startPoint, endPoint);
	anim.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
		@Override
		public void onAnimationUpdate(ValueAnimator animation) {
			currentPoint = (Point) animation.getAnimatedValue();
			invalidate();
		}
	});
	ObjectAnimator anim2 = ObjectAnimator.ofObject(this, "color", new ColorEvaluator(),
			"#00FFFF", "#FF1100");
	AnimatorSet animSet = new AnimatorSet();
	animSet.play(anim).with(anim2);
	animSet.setDuration(5000);
	animSet.start();
}
 
Example 5
Source File: GestureView.java    From Jockey with Apache License 2.0 6 votes vote down vote up
/**
 * Animates the overlay to a specified radius, fades it out, and clears the current gesture
 * @param targetRadius The radius to animate the circular overlay to
 * @param time The time for this animation to last
 * @param alphaDelay An optional delay to add before animating the transparency of the overlay
 */
private void animateOutRadius(int targetRadius, int time, int alphaDelay) {
    ObjectAnimator alphaAnim = ObjectAnimator.ofObject(
            this, "overlayAlpha",
            new IntEvaluator(), mAlpha, 0);
    ObjectAnimator radiusAnim = ObjectAnimator.ofObject(
            this, "radius",
            new IntEvaluator(), (isRight() ? radius() : -radius()), targetRadius);

    radiusAnim
            .setDuration(time)
            .setInterpolator(AnimationUtils.loadInterpolator(getContext(),
                    android.R.interpolator.accelerate_quad));
    alphaAnim
            .setDuration(time)
            .setInterpolator(AnimationUtils.loadInterpolator(getContext(),
                    android.R.interpolator.accelerate_quad));

    radiusAnim.start();
    alphaAnim.setStartDelay(alphaDelay);
    alphaAnim.start();
}
 
Example 6
Source File: DefaultLoadingState.java    From empty-state-recyclerview with MIT License 6 votes vote down vote up
@Override
public void onDrawState(final EmptyStateRecyclerView rv, Canvas canvas) {
    canvas.drawText(title,
            (rv.getMeasuredWidth() >> 1),
            (rv.getMeasuredHeight() >> 1),
            textPaint);

    // Setup animator, if necessary
    if (anim == null) {
        this.anim = ObjectAnimator.ofObject(textPaint, "color", new ArgbEvaluator(),
                Color.parseColor("#E0E0E0"), Color.parseColor("#BDBDBD"), Color.parseColor("#9E9E9E"));
        this.anim.setDuration(900);
        this.anim.setRepeatMode(ValueAnimator.REVERSE);
        this.anim.setRepeatCount(ValueAnimator.INFINITE);
        this.anim.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
            @Override
            public void onAnimationUpdate(ValueAnimator animation) {
                rv.invalidate();
            }
        });
        this.anim.start();
    }
}
 
Example 7
Source File: ObjectPropertyAnimActivity.java    From AndroidStudyDemo with GNU General Public License v2.0 6 votes vote down vote up
public void startRectAnimation(View v) {
    Rect local = new Rect();
    mShowAnimIV.getLocalVisibleRect(local);
    Rect from = new Rect(local);
    Rect to = new Rect(local);

    from.right = from.left + local.width()/4;
    from.bottom = from.top + local.height()/2;

    to.left = to.right - local.width()/2;
    to.top = to.bottom - local.height()/4;

    if (Build.VERSION.SDK_INT >= 18) {
        ObjectAnimator objectAnimator = ObjectAnimator.ofObject(mShowAnimIV, "clipBounds", new RectEvaluator(), from, to);
        objectAnimator.setDuration(C.Int.ANIM_DURATION * 4);
        objectAnimator.start();
    }
}
 
Example 8
Source File: AnimatorFactory.java    From scene with Apache License 2.0 5 votes vote down vote up
public Animator toAnimator() {
    Animator animator = ObjectAnimator.ofObject(mTarget, mProperty, mTypeEvaluator, mStartValue, mEndValue);
    if (this.mInterpolator != null) {
        animator.setInterpolator(this.mInterpolator);
    }
    return animator;
}
 
Example 9
Source File: CustomEvaluator.java    From AnimationApiDemos with Apache License 2.0 5 votes vote down vote up
private void createAnimation() {
	if (bounceAnim == null) {
		XYHolder startXY = new XYHolder(0f, 0f);
		XYHolder endXY = new XYHolder(300f, 500f);

		// ObjectAnimator的构造使用了ofObject形式的工厂方法,传入了自定义的evaluator对象
		bounceAnim = ObjectAnimator.ofObject(ballHolder, "xY",
				new XYEvaluator(), startXY, endXY);
		// 也可以不提供初始值,如下写:
		// bounceAnim = ObjectAnimator.ofObject(ballHolder, "xY",
		// new XYEvaluator(), endXY);
		bounceAnim.setDuration(1500);
		bounceAnim.addUpdateListener(this);
	}
}
 
Example 10
Source File: CustomEvaluator.java    From codeexamples-android with Eclipse Public License 1.0 5 votes vote down vote up
private void createAnimation() {
    if (bounceAnim == null) {
        XYHolder startXY = new XYHolder(0f, 0f);
        XYHolder endXY = new XYHolder(300f, 500f);
        bounceAnim = ObjectAnimator.ofObject(ballHolder, "xY",
                new XYEvaluator(), endXY);
        bounceAnim.setDuration(1500);
        bounceAnim.addUpdateListener(this);
    }
}
 
Example 11
Source File: PropertyAnimation06.java    From cogitolearning-examples with MIT License 5 votes vote down vote up
public void startHsvAnimation(View view)
{
  View square = findViewById(R.id.some_view);
  
  ObjectAnimator anim = ObjectAnimator.ofObject(square, "backgroundColor", new HsvEvaluator(), Color.RED, Color.BLUE);
  anim.setDuration(2000);
  anim.start();
}
 
Example 12
Source File: ViewPathAnimator.java    From AndroidLinkup with GNU General Public License v2.0 5 votes vote down vote up
/**
 * 设置动画的起始点
 * 
 * @param pathPoints
 *            路径点
 */
public void animatePath(List<Point> pathPoints) {
    if (pathPoints == null || pathPoints.size() == 0) {
        return;
    }
    AnimatorPath path = new AnimatorPath();
    path.moveTo(pathPoints.get(0).x, pathPoints.get(0).y);
    for (int i = 1; i < pathPoints.size(); i++) {
        path.lineTo(pathPoints.get(i).x, pathPoints.get(i).y);
    }
    ObjectAnimator anim = ObjectAnimator.ofObject(view, "location", new PathEvaluator(), path.getPoints().toArray());
    anim.addListener(this);
    anim.setDuration(duration);
    anim.start();
}
 
Example 13
Source File: ObjectPropertyAnimActivity.java    From AndroidStudyDemo with GNU General Public License v2.0 4 votes vote down vote up
public void startRGBAnimation(View v) {
    ObjectAnimator objectAnimator = ObjectAnimator.ofObject(mShowAnimView, "backgroundColor", new ArgbEvaluator(), Color.RED, Color.BLUE);
    objectAnimator.setDuration(C.Int.ANIM_DURATION * 4);
    objectAnimator.start();
}
 
Example 14
Source File: AnimatorValueImplements.java    From TikTok with Apache License 2.0 4 votes vote down vote up
public ObjectAnimator createProNameObject(Object object,TypeEvaluator<Object> typeEvaluator, String proName, Object... values) {
	objectAnimator=ObjectAnimator.ofObject(object, proName, typeEvaluator, values);
	return objectAnimator;
}
 
Example 15
Source File: RootActivity.java    From Depth with MIT License 4 votes vote down vote up
private void fadeColoTo(int newColor, TextView view) {

        ObjectAnimator color = ObjectAnimator.ofObject(view, "TextColor", new ArgbEvaluator(), view.getCurrentTextColor(), newColor);
        color.setDuration(200);
        color.start();
    }
 
Example 16
Source File: ObjectPropertyAnimActivity.java    From AndroidStudyDemo with GNU General Public License v2.0 4 votes vote down vote up
public void startHsvAnimation(View v) {
    ObjectAnimator objectAnimator = ObjectAnimator.ofObject(mShowAnimView, "backgroundColor", new HsvEvaluator(), Color.RED, Color.BLUE);
    objectAnimator.setDuration(C.Int.ANIM_DURATION * 4);
    objectAnimator.start();
}
 
Example 17
Source File: ColorAnimator.java    From HaiNaBaiChuan with Apache License 2.0 4 votes vote down vote up
public static ObjectAnimator ofBackgroundColor(View target, int to) {
	return ObjectAnimator.ofObject(new ViewBackgroundWrapper(target), "backgroundColor", new ColorEvaluator(), to);
}
 
Example 18
Source File: ColorAnimator.java    From HaiNaBaiChuan with Apache License 2.0 4 votes vote down vote up
public static ObjectAnimator ofColor(Object target, String propertyName, int from, int to) {
	return ObjectAnimator.ofObject(target, propertyName, new ColorEvaluator(), from, to);
}
 
Example 19
Source File: ColorAnimator.java    From Android-Plugin-Framework with MIT License 4 votes vote down vote up
public static ObjectAnimator ofColor(Object target, String propertyName, int to) {
  return ObjectAnimator.ofObject(target, propertyName, new ColorEvaluator(), to);
}
 
Example 20
Source File: ChangeImageTransform.java    From android_9.0.0_r45 with Apache License 2.0 4 votes vote down vote up
private ObjectAnimator createNullAnimator(ImageView imageView) {
    return ObjectAnimator.ofObject(imageView, ANIMATED_TRANSFORM_PROPERTY,
            NULL_MATRIX_EVALUATOR, null, null);
}