Java Code Examples for com.nineoldandroids.animation.ObjectAnimator#setDuration()

The following examples show how to use com.nineoldandroids.animation.ObjectAnimator#setDuration() . 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: Delegate.java    From MousePaint with MIT License 6 votes vote down vote up
/**
 * 显示模糊背景
 */
protected void showShowdown() {

    ViewHelper.setTranslationY(mRootView, 0);
    mEffect.effect(mParentVG,mBg);
    ViewGroup.LayoutParams lp =
            new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT);

    if(mBg.getParent()!= null){
        mParentVG.removeView(mBg);
    }

    mParentVG.addView(mBg, lp);
    ViewHelper.setAlpha(mBg, 0);
    ObjectAnimator objectAnimator = ObjectAnimator.ofFloat(mBg, "alpha", 0, 1);
    objectAnimator.setDuration(400);
    objectAnimator.start();
}
 
Example 2
Source File: SimpleAnimation.java    From Android-PullToNextLayout with Apache License 2.0 6 votes vote down vote up
public Animator getPullDownAnimIn(View view) {

        ObjectAnimator in = ObjectAnimator.ofFloat(view, "translationY", -view.getMeasuredHeight(), 0);

        ObjectAnimator scaleY = ObjectAnimator.ofFloat(view, "scaleY", 0.6f, 1);
        ObjectAnimator scaleX = ObjectAnimator.ofFloat(view, "scaleX", 0.6f, 1);

        AnimatorSet set = new AnimatorSet();
        set.setInterpolator(new DecelerateInterpolator());
        in.setDuration(ANIMATION_DURATION);
        scaleY.setDuration(ANIMATION_DURATION);
        scaleX.setDuration(ANIMATION_DURATION);
        set.setDuration(ANIMATION_DURATION);
        set.playTogether(scaleY, scaleX, in);


        return set;
    }
 
Example 3
Source File: Switch.java    From MaterialDesignLibrary with Apache License 2.0 5 votes vote down vote up
public void animateCheck() {
	changeBackground();
	ObjectAnimator objectAnimator;
	if (eventCheck) {
		objectAnimator = ObjectAnimator.ofFloat(this, "x", ball.xFin);

	} else {
		objectAnimator = ObjectAnimator.ofFloat(this, "x", ball.xIni);
	}
	objectAnimator.setDuration(300);
	objectAnimator.start();
}
 
Example 4
Source File: ButtonFloat.java    From MaterialDesignLibrary with Apache License 2.0 5 votes vote down vote up
public void hide(){
	
	ObjectAnimator animator = ObjectAnimator.ofFloat(ButtonFloat.this, "y", hidePosition);
	animator.setInterpolator(new BounceInterpolator());
	animator.setDuration(1500);
	animator.start();
	
	isShow = false;
}
 
Example 5
Source File: MenuRVAdapter.java    From AndroidSweetSheet with Apache License 2.0 5 votes vote down vote up
private void animation(MenuVH menuVH) {

        ViewHelper.setAlpha(menuVH.itemView, 0);

        ViewHelper.setTranslationY(menuVH.itemView, 300);
        ObjectAnimator translationY = ObjectAnimator.ofFloat(menuVH.itemView, "translationY", 500, 0);
        translationY.setDuration(300);
        translationY.setInterpolator(new OvershootInterpolator(1.6f));
        ObjectAnimator alphaIn = ObjectAnimator.ofFloat(menuVH.itemView, "alpha", 0, 1);
        alphaIn.setDuration(100);
        AnimatorSet animatorSet = new AnimatorSet();
        animatorSet.playTogether(translationY, alphaIn);
        animatorSet.setStartDelay(30 * menuVH.getAdapterPosition());
        animatorSet.start();
    }
 
Example 6
Source File: AnimationUtil.java    From sms-ticket with Apache License 2.0 5 votes vote down vote up
public static void setFlipAnimation(final ImageView view, final ObjectAnimator animator, final int firstImage,
                                    final int secondImage, final Context c) {
    if (secondImage == NO_ANIMATION) {
        view.setImageResource(firstImage);
        animator.end();
        ViewCompat.setHasTransientState(view, false);
    } else {
        animator.setRepeatCount(ObjectAnimator.INFINITE);
        animator.setDuration(1300);
        animator.setInterpolator(new LinearInterpolator());
        animator.setRepeatMode(ValueAnimator.RESTART);

        animator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
            final Drawable shape1 = c.getResources().getDrawable(firstImage);
            final Drawable shape2 = c.getResources().getDrawable(secondImage);
            Drawable currentDrawable = null;

            @Override
            public void onAnimationUpdate(ValueAnimator animation) {
                float angle = (Float)animation.getAnimatedValue();
                int quadrant = (int)(angle / 90) + 1;
                if ((quadrant == 1 || quadrant == 4) && shape1 != currentDrawable) {
                    view.setImageDrawable(shape1);
                    currentDrawable = shape1;
                } else if ((quadrant == 2 || quadrant == 3) && currentDrawable != shape2) {
                    view.setImageDrawable(shape2);
                    currentDrawable = shape2;
                }
            }
        });
        animator.start();
        ViewCompat.setHasTransientState(view, true);
    }
}
 
Example 7
Source File: TutorialActivity.java    From PhoneTutorial with Apache License 2.0 5 votes vote down vote up
private void animate(){
	ObjectAnimator animator1 = ObjectAnimator.ofFloat(imageContainer, "x", -(position*width));
	animator1.setDuration(300);
	animator1.start();
	ObjectAnimator animator2 = ObjectAnimator.ofFloat(titleContainer, "x", -(position*widthTitle));
	animator2.setDuration(300);
	animator2.start();
}
 
Example 8
Source File: ButtonFloat.java    From MoeGallery with GNU General Public License v3.0 5 votes vote down vote up
public void hide() {

        ObjectAnimator animator = ObjectAnimator.ofFloat(ButtonFloat.this, "y", hidePosition);
        animator.setInterpolator(new BounceInterpolator());
        animator.setDuration(1500);
        animator.start();

        isShow = false;
    }
 
Example 9
Source File: AnimatedPathView.java    From google-io-2014-compat with Apache License 2.0 5 votes vote down vote up
public void reveal() {
    ObjectAnimator svgAnimator = ObjectAnimator.ofFloat(this, "phase", 1.0f, 0.0f);
    svgAnimator.setDuration(mDuration);
    svgAnimator.start();

    setFillAlpha(0.0f);

    ObjectAnimator fillAnimator = ObjectAnimator.ofFloat(this, "fillAlpha", 0.0f, 1.0f);
    fillAnimator.setDuration(mFillDuration);
    fillAnimator.setStartDelay(mFillOffset);
    fillAnimator.start();
}
 
Example 10
Source File: Switch.java    From XERUNG with Apache License 2.0 5 votes vote down vote up
public void animateCheck() {
	changeBackground();
	ObjectAnimator objectAnimator;
	if (iSchecked) {
		objectAnimator = ObjectAnimator.ofFloat(this, "x", ball.xFin);

	} else {
		objectAnimator = ObjectAnimator.ofFloat(this, "x", ball.xIni);
	}
	objectAnimator.setDuration(300);
	objectAnimator.start();
}
 
Example 11
Source File: Ripple.java    From Mover with Apache License 2.0 5 votes vote down vote up
/**
 * Starts the enter animation.
 */
public void enter() {
    cancel();

    final int radiusDuration = (int)
            (1000 * Math.sqrt(mOuterRadius / WAVE_TOUCH_DOWN_ACCELERATION * mDensity) + 0.5);

    final ObjectAnimator radius = ObjectAnimator.ofFloat(this, "radiusGravity", 1);
    radius.setAutoCancel(true);
    radius.setDuration(radiusDuration);
    radius.setInterpolator(LINEAR_INTERPOLATOR);
    radius.setStartDelay(RIPPLE_ENTER_DELAY);

    final ObjectAnimator cX = ObjectAnimator.ofFloat(this, "xGravity", 1);
    cX.setAutoCancel(true);
    cX.setDuration(radiusDuration);
    cX.setInterpolator(LINEAR_INTERPOLATOR);
    cX.setStartDelay(RIPPLE_ENTER_DELAY);

    final ObjectAnimator cY = ObjectAnimator.ofFloat(this, "yGravity", 1);
    cY.setAutoCancel(true);
    cY.setDuration(radiusDuration);
    cY.setInterpolator(LINEAR_INTERPOLATOR);
    cY.setStartDelay(RIPPLE_ENTER_DELAY);

    mAnimRadius = radius;
    mAnimX = cX;
    mAnimY = cY;

    // Enter animations always run on the UI thread, since it's unlikely
    // that anything interesting is happening until the user lifts their
    // finger.
    radius.start();
    cX.start();
    cY.start();
}
 
Example 12
Source File: SwitchAnimationUtil.java    From UltimateAndroid with Apache License 2.0 5 votes vote down vote up
private void runAlphaAnimation(View view, long delay) {
	view.setAlpha(0);
	ObjectAnimator objectAnimator = ObjectAnimator.ofFloat(view, "alpha",
			0, 1);
	objectAnimator.setStartDelay(delay);
	objectAnimator.setDuration(mDuration);
	objectAnimator.setInterpolator(new LinearInterpolator());
	objectAnimator.start();
}
 
Example 13
Source File: MenuRVAdapter.java    From MousePaint with MIT License 5 votes vote down vote up
private void animation(MenuVH menuVH) {

        ViewHelper.setAlpha(menuVH.itemView, 0);

        ViewHelper.setTranslationY(menuVH.itemView, 300);
        ObjectAnimator translationY = ObjectAnimator.ofFloat(menuVH.itemView, "translationY", 500, 0);
        translationY.setDuration(300);
        translationY.setInterpolator(new OvershootInterpolator(1.6f));
        ObjectAnimator alphaIn = ObjectAnimator.ofFloat(menuVH.itemView, "alpha", 0, 1);
        alphaIn.setDuration(100);
        AnimatorSet animatorSet = new AnimatorSet();
        animatorSet.playTogether(translationY, alphaIn);
        animatorSet.setStartDelay(30 * menuVH.getAdapterPosition());
        animatorSet.start();
    }
 
Example 14
Source File: ButtonFloat.java    From PhoneTutorial with Apache License 2.0 5 votes vote down vote up
public void hide(){
	
	ObjectAnimator animator = ObjectAnimator.ofFloat(ButtonFloat.this, "y", hidePosition);
	animator.setInterpolator(new BounceInterpolator());
	animator.setDuration(1500);
	animator.start();
	
	isShow = false;
}
 
Example 15
Source File: IndicatorView.java    From AndroidSweetSheet with Apache License 2.0 5 votes vote down vote up
public void alphaShow(boolean isAnimation){

        if(isAnimation) {
            ObjectAnimator objectAnimator = ObjectAnimator.ofFloat(this, "alpha", 0, 1);
            objectAnimator.setDuration(300);
            objectAnimator.start();
        }else{
            ViewHelper.setAlpha(this,1);
        }
    }
 
Example 16
Source File: RippleLayout.java    From ripplelayout with MIT License 5 votes vote down vote up
/**
 * 为每个RippleView添加动画效果,并且设置动画延时,每个视图启动动画的时间不同,就会产生波纹
 * 
 * @param rippleView
 * @param i 视图所在的索引
 */
private void addAnimToRippleView(RippleView rippleView, int i) {

    // x轴的缩放动画
    final ObjectAnimator scaleXAnimator = ObjectAnimator.ofFloat(rippleView, "scaleX",
            1.0f, mRippleScale);
    scaleXAnimator.setRepeatCount(ObjectAnimator.INFINITE);
    scaleXAnimator.setRepeatMode(ObjectAnimator.RESTART);
    scaleXAnimator.setStartDelay(i * mAnimDelay);
    scaleXAnimator.setDuration(mAnimDuration);
    mAnimatorList.add(scaleXAnimator);

    // y轴的缩放动画
    final ObjectAnimator scaleYAnimator = ObjectAnimator.ofFloat(rippleView, "scaleY",
            1.0f, mRippleScale);
    scaleYAnimator.setRepeatMode(ObjectAnimator.RESTART);
    scaleYAnimator.setRepeatCount(ObjectAnimator.INFINITE);
    scaleYAnimator.setStartDelay(i * mAnimDelay);
    scaleYAnimator.setDuration(mAnimDuration);
    mAnimatorList.add(scaleYAnimator);

    // 颜色的alpha渐变动画
    final ObjectAnimator alphaAnimator = ObjectAnimator.ofFloat(rippleView, "alpha", 1.0f,
            0f);
    alphaAnimator.setRepeatMode(ObjectAnimator.RESTART);
    alphaAnimator.setRepeatCount(ObjectAnimator.INFINITE);
    alphaAnimator.setDuration(mAnimDuration);
    alphaAnimator.setStartDelay(i * mAnimDelay);
    mAnimatorList.add(alphaAnimator);
}
 
Example 17
Source File: AnimationListView.java    From AnimationListView with Apache License 2.0 5 votes vote down vote up
protected ObjectAnimator animateY(final View view, final float oldY, final float newY,
		final float durationUnit) {
	final int duration = getDuration(oldY, newY, durationUnit);

	final ObjectAnimator anim = ObjectAnimator.ofFloat(AnimatorProxy.wrap(view),
			"translationY", oldY - newY, 0);

	final int finalDuration = Math
			.min(Math.max(duration, MIN_ANIM_DURATION), MAX_ANIM_DURATION);

	anim.setDuration((long) (finalDuration * animationDurationFactor));
	anim.setInterpolator(translateInterpolater);

	return anim;
}
 
Example 18
Source File: CurveAction.java    From android-player with Apache License 2.0 5 votes vote down vote up
@Override
public void animate(View view) {
    final ObjectAnimator anim = ObjectAnimator.ofObject(this, PATH_POINT_LOCATION,
            new PathEvaluator(), path.getPoints().toArray());

    anim.setInterpolator(getInterpolator());
    anim.setDuration(getDuration());
    anim.start();
}
 
Example 19
Source File: SimpleAnimation.java    From Android-PullToNextLayout with Apache License 2.0 4 votes vote down vote up
private Animator getPullUpAnimOut(View view) {
    ObjectAnimator out = ObjectAnimator.ofFloat(view, "translationY", 0, -view.getMeasuredHeight());
    out.setDuration(ANIMATION_DURATION);
    return out;
}
 
Example 20
Source File: CustomDelegate.java    From MousePaint with MIT License 3 votes vote down vote up
private void alphaAnimation() {


        ObjectAnimator objectAnimator = ObjectAnimator.ofFloat(getContentRelativeLayout(), "alpha", 0, 1);
        objectAnimator.setDuration(1200);
        objectAnimator.setInterpolator(new DecelerateInterpolator());
        objectAnimator.start();


    }