com.nineoldandroids.animation.ObjectAnimator Java Examples

The following examples show how to use com.nineoldandroids.animation.ObjectAnimator. 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: PlayerDiscView.java    From SimplifyReader with Apache License 2.0 6 votes vote down vote up
private void startNeedleAnimator() {
    if (isPlaying) {
        mNeedleAnimator = ObjectAnimator.ofFloat(mNeedle, "rotation", 0, NEEDLE_ROTATE_CIRCLE);
    } else {
        mNeedleAnimator = ObjectAnimator.ofFloat(mNeedle, "rotation", NEEDLE_ROTATE_CIRCLE, 0);
    }

    mNeedleAnimator.setDuration(NEEDLE_ANIMATOR_TIME);
    mNeedleAnimator.setInterpolator(new DecelerateInterpolator());

    if (mNeedleAnimator.isRunning() || mNeedleAnimator.isStarted()) {
        mNeedleAnimator.cancel();
    }

    mNeedleAnimator.start();
}
 
Example #2
Source File: ResideMenu.java    From AndroidResideMenu with MIT License 6 votes vote down vote up
/**
 * A helper method to build scale up animation;
 *
 * @param target
 * @param targetScaleX
 * @param targetScaleY
 * @return
 */
private AnimatorSet buildScaleUpAnimation(View target, float targetScaleX, float targetScaleY) {

    AnimatorSet scaleUp = new AnimatorSet();
    scaleUp.playTogether(
            ObjectAnimator.ofFloat(target, "scaleX", targetScaleX),
            ObjectAnimator.ofFloat(target, "scaleY", targetScaleY)
    );

    if (mUse3D) {
        scaleUp.playTogether(ObjectAnimator.ofFloat(target, "rotationY", 0));
    }

    scaleUp.setDuration(250);
    return scaleUp;
}
 
Example #3
Source File: LoadingImageView.java    From LoadingImageView with MIT License 6 votes vote down vote up
private void initAnim() {
    stopAnim();
    //animator = ObjectAnimator.ofInt(this, "maskHeight", 0, imageHeight);
    animator = ObjectAnimator.ofInt(clipDrawable, "level", 0, 10000);
    animator.setDuration(animDuration);
    animator.setRepeatCount(ValueAnimator.INFINITE);
    animator.setRepeatMode(ValueAnimator.RESTART);
    animator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
        @Override
        public void onAnimationUpdate(ValueAnimator animation) {
            invalidate();
        }
    });
    if(autoStart){
        animator.start();
    }
}
 
Example #4
Source File: Delegate.java    From MousePaint with MIT License 6 votes vote down vote up
/**
 * 隐藏模糊背景
 */
protected void dismissShowdown() {

    ObjectAnimator objectAnimator = ObjectAnimator.ofFloat(mBg, "alpha", 1, 0);
    objectAnimator.setDuration(400);
    objectAnimator.start();
    objectAnimator.addListener(new SimpleAnimationListener() {

        @Override
        public void onAnimationEnd(Animator animation) {

            mParentVG.removeView(mBg);
        }


    });
}
 
Example #5
Source File: RadialSelectorView.java    From Conquer with Apache License 2.0 6 votes vote down vote up
public ObjectAnimator getDisappearAnimator() {
    if (!mIsInitialized || !mDrawValuesReady) {
        Log.e(TAG, "RadialSelectorView was not ready for animation.");
        return null;
    }

    Keyframe kf0, kf1, kf2;
    float midwayPoint = 0.2f;
    int duration = 500;

    kf0 = Keyframe.ofFloat(0f, 1);
    kf1 = Keyframe.ofFloat(midwayPoint, mTransitionMidRadiusMultiplier);
    kf2 = Keyframe.ofFloat(1f, mTransitionEndRadiusMultiplier);
    PropertyValuesHolder radiusDisappear = PropertyValuesHolder.ofKeyframe(
            "animationRadiusMultiplier", kf0, kf1, kf2);

    kf0 = Keyframe.ofFloat(0f, 1f);
    kf1 = Keyframe.ofFloat(1f, 0f);
    PropertyValuesHolder fadeOut = PropertyValuesHolder.ofKeyframe("alpha", kf0, kf1);

    ObjectAnimator disappearAnimator = ObjectAnimator.ofPropertyValuesHolder(
            this, radiusDisappear, fadeOut).setDuration(duration);
    disappearAnimator.addUpdateListener(mInvalidateUpdateListener);

    return disappearAnimator;
}
 
Example #6
Source File: PlayerDiscView.java    From SimplifyReader with Apache License 2.0 6 votes vote down vote up
private void startDiscAnimator(float animatedValue) {
    mDiscLayoutAnimator = ObjectAnimator.ofFloat(mDiscLayout, "rotation", animatedValue, 360 + animatedValue);
    mDiscLayoutAnimator.addUpdateListener(new AnimatorUpdateListener() {

        @Override
        public void onAnimationUpdate(ValueAnimator arg0) {
            mDiscLayoutAnimatorValue = (Float) arg0.getAnimatedValue();
        }
    });
    mDiscLayoutAnimator.setDuration(DISC_ANIMATOR_TIME);
    mDiscLayoutAnimator.setRepeatCount(DISC_ANIMATOR_REPEAT_COUNT);
    mDiscLayoutAnimator.setInterpolator(new LinearInterpolator());

    if (mDiscLayoutAnimator.isRunning() || mDiscLayoutAnimator.isStarted()) {
        mDiscLayoutAnimator.cancel();
    }

    mDiscLayoutAnimator.start();
}
 
Example #7
Source File: SwitchAnimationUtil.java    From UltimateAndroid with Apache License 2.0 6 votes vote down vote up
private void runRotateAnimation(View view, long delay) {
	view.setAlpha(0);
	AnimatorSet set = new AnimatorSet();
	ObjectAnimator objectAnimator = ObjectAnimator.ofFloat(view,
			"rotation", 0f, 360f);
	ObjectAnimator objectAnimator2 = ObjectAnimator.ofFloat(view, "scaleX",
			0f, 1f);
	ObjectAnimator objectAnimator3 = ObjectAnimator.ofFloat(view, "scaleY",
			0f, 1f);
	ObjectAnimator objectAnimator4 = ObjectAnimator.ofFloat(view, "alpha",
			0f, 1f);

	objectAnimator2.setInterpolator(new AccelerateInterpolator(1.0f));
	objectAnimator3.setInterpolator(new AccelerateInterpolator(1.0f));

	set.setDuration(mDuration);
	set.playTogether(objectAnimator, objectAnimator2, objectAnimator3,
			objectAnimator4);
	set.setStartDelay(delay);
	set.start();
}
 
Example #8
Source File: CardFaceView.java    From CardView with Apache License 2.0 6 votes vote down vote up
private void onFlagChanged(final CardFlag oldFlag, final CardFlag newFlag) {
	int flagColor = CARD_BACKGROUND_COLOR_NOFLAG;
	if (newFlag != null) {
		flagColor = newFlag.getColor();
	}
	
	ValueAnimator fade = ObjectAnimator.ofInt(mCardPaint,
			"color", mCardPaint.getColor(), flagColor);
	fade.setDuration(500);
	fade.setEvaluator(new ArgbEvaluator());
	fade.addUpdateListener(new AnimatorUpdateListener() {
		@Override
		public void onAnimationUpdate(ValueAnimator value) {
			onFlagChangedUpdate(oldFlag, newFlag, value);
			invalidate();
		}
	});
	
	fade.start();
}
 
Example #9
Source File: QuickAttachmentDrawer.java    From deltachat-android with GNU General Public License v3.0 6 votes vote down vote up
private void slideTo(int slideOffset, boolean forceInstant) {
  if (animator != null) {
    animator.cancel();
    animator = null;
  }

  if (!forceInstant) {
    animator = ObjectAnimator.ofInt(this, "slideOffset", this.slideOffset, slideOffset);
    animator.setInterpolator(new FastOutSlowInInterpolator());
    animator.setDuration(400);
    animator.start();
    ViewCompat.postInvalidateOnAnimation(this);
  } else {
    this.slideOffset = slideOffset;
    requestLayout();
    invalidate();
  }
}
 
Example #10
Source File: DynamicFormActivity.java    From Android-Anim-Playground with MIT License 6 votes vote down vote up
private void slideInToTop(View editContainer, View movableView)
{
    View v = findViewById(R.id.edit_mode_container);

    //put edit at the bottom
    Log.d(TAG, "container view height :" + String.valueOf(v.getHeight()));

    ObjectAnimator anim = ObjectAnimator.ofFloat(v, "translationY", mMainContainer.getHeight());
    anim.setDuration(0);
    anim.start();

    v.setVisibility(View.VISIBLE);

    AnimatorSet set = new AnimatorSet();
    set.playTogether(
            ObjectAnimator.ofFloat(v, "translationY", editContainer.getTop()+movableView.getHeight()+modeContainerMargin),
            ObjectAnimator.ofFloat(v, "alpha", 0, 1)
    );
    set.setDuration(ANIMATION_DURATION);
    set.setInterpolator(ANIMATION_INTERPOLATOR);
    set.start();

}
 
Example #11
Source File: FlipInXAnimator.java    From UltimateAndroid with Apache License 2.0 5 votes vote down vote up
@Override
public void prepare(View target) {
    getAnimatorAgent().playTogether(
            ObjectAnimator.ofFloat(target, "rotationX", 90, -15, 15, 0),
            ObjectAnimator.ofFloat(target, "alpha", 0.25f, 0.5f, 0.75f, 1)
    );
}
 
Example #12
Source File: Utils.java    From Conquer with Apache License 2.0 5 votes vote down vote up
public static ObjectAnimator getPulseAnimator(View labelToAnimate, float decreaseRatio, float increaseRatio) {
    Keyframe k0 = Keyframe.ofFloat(0f, 1f);
    Keyframe k1 = Keyframe.ofFloat(0.275f, decreaseRatio);
    Keyframe k2 = Keyframe.ofFloat(0.69f, increaseRatio);
    Keyframe k3 = Keyframe.ofFloat(1f, 1f);

    PropertyValuesHolder scaleX = PropertyValuesHolder.ofKeyframe("scaleX", k0, k1, k2, k3);
    PropertyValuesHolder scaleY = PropertyValuesHolder.ofKeyframe("scaleY", k0, k1, k2, k3);
    ObjectAnimator pulseAnimator = ObjectAnimator.ofPropertyValuesHolder(labelToAnimate, scaleX, scaleY);
    pulseAnimator.setDuration(PULSE_ANIMATOR_DURATION);

    return pulseAnimator;
}
 
Example #13
Source File: RotateOutUpRightAnimator.java    From UltimateAndroid with Apache License 2.0 5 votes vote down vote up
@Override
public void prepare(View target) {
    float x = target.getWidth() - target.getPaddingRight();
    float y = target.getHeight() - target.getPaddingBottom();
    getAnimatorAgent().playTogether(
            ObjectAnimator.ofFloat(target, "alpha", 1, 0),
            ObjectAnimator.ofFloat(target,"rotation",0,90),
            ObjectAnimator.ofFloat(target,"pivotX",x,x),
            ObjectAnimator.ofFloat(target,"pivotY",y,y)
    );
}
 
Example #14
Source File: VideoViewActivity.java    From MyHearts with Apache License 2.0 5 votes vote down vote up
private void startLoadingAnimator() {
    if (mOjectAnimator == null) {
        mOjectAnimator = ObjectAnimator.ofFloat(mLoadingImg, "rotation", 0f, 360f);
    }
    mLoadinglinearlayout.setVisibility(View.VISIBLE);

    mOjectAnimator.setDuration(1000);
    mOjectAnimator.setRepeatCount(-1);
    mOjectAnimator.start();
}
 
Example #15
Source File: ProgressView.java    From Android-Anim-Playground with MIT License 5 votes vote down vote up
private void init() {
    mPaint.setStyle(Paint.Style.STROKE);

    createWaitPath();

    mWaitAnimator = ObjectAnimator.ofFloat(this, "wait", 1.0f, 0.0f).setDuration(mDuration);
    mWaitAnimator.setRepeatMode(ObjectAnimator.RESTART);
    mWaitAnimator.setRepeatCount(ObjectAnimator.INFINITE);
    mWaitAnimator.setInterpolator(new LinearInterpolator());
    mWaitAnimator.start();
}
 
Example #16
Source File: MaterialCompoundButton.java    From MaterialRadioGroup with Apache License 2.0 5 votes vote down vote up
private void end() {
    if(canAnimate()){
        clearAnimation();
    }
    AnimatorSet animatorSet = new AnimatorSet();
    animatorSet.play(ObjectAnimator.ofFloat(this, "scaleX", 0.85f));
    animatorSet.play(ObjectAnimator.ofFloat(this, "scaleY", 0.85f));
    animatorSet.setInterpolator(new OvershootInterpolator());
    animatorSet.setDuration(getDuration());
    animatorSet.start();
}
 
Example #17
Source File: Scale2Animater.java    From JPTabBar with Apache License 2.0 5 votes vote down vote up
@Override
public void onSelectChanged(View v, boolean selected) {
    if(!selected)return;
    AnimatorSet set= new AnimatorSet();
    ObjectAnimator animator1 = ObjectAnimator.ofFloat(v,"scaleX",0.75f,1.3f,1f,1.2f,1f);
    ObjectAnimator animator2 = ObjectAnimator.ofFloat(v,"scaleY",0.75f,1.3f,1f,1.2f,1f);
    set.playTogether(animator1,animator2);
    set.setDuration(800);
    set.start();

}
 
Example #18
Source File: EmoticonsIndicatorView.java    From BigApp_Discuz_Android with Apache License 2.0 5 votes vote down vote up
private AnimatorSet getAnimPointOut(ImageView imageViewStrat) {
    ObjectAnimator anim1 = ObjectAnimator.ofFloat(imageViewStrat, "scaleX", 1.0f, 0.25f);
    ObjectAnimator anim2 = ObjectAnimator.ofFloat(imageViewStrat, "scaleY", 1.0f, 0.25f);
    mPlayByOutAnimatorSet = new AnimatorSet();
    mPlayByOutAnimatorSet.play(anim1).with(anim2);
    mPlayByOutAnimatorSet.setDuration(100);

    return mPlayByInAnimatorSet;
}
 
Example #19
Source File: DotStyleHorizontalRightRefreshViewHolder.java    From ht-refreshrecyclerview with MIT License 5 votes vote down vote up
@Override
public void onRefreshing() {
    mRefreshLoadView.setPivotX(0.5f * mRefreshLoadView.getMeasuredWidth());
    mRefreshLoadView.setPivotY(0.5f * mRefreshLoadView.getMeasuredHeight());
    if (animator == null) {
        animator = ObjectAnimator.ofFloat(mRefreshLoadView, "rotation", 0.0f, 360.0f);
        animator.setDuration(1000);
        animator.setRepeatCount(ValueAnimator.INFINITE);
        animator.setRepeatMode(ValueAnimator.RESTART);
    }
    if (animator.isRunning()) animator.cancel();
    animator.start();
}
 
Example #20
Source File: SlideInLeftAnimator.java    From UltimateAndroid with Apache License 2.0 5 votes vote down vote up
@Override
public void prepare(View target) {
    ViewGroup parent = (ViewGroup)target.getParent();
    int distance = parent.getWidth() - target.getLeft();
    getAnimatorAgent().playTogether(
            ObjectAnimator.ofFloat(target, "alpha", 0, 1),
            ObjectAnimator.ofFloat(target,"translationX",-distance,0)
    );
}
 
Example #21
Source File: BounceInDownAnimator.java    From UltimateAndroid with Apache License 2.0 5 votes vote down vote up
@Override
public void prepare(View target) {
    getAnimatorAgent().playTogether(
            ObjectAnimator.ofFloat(target,"alpha",0,1,1,1),
            ObjectAnimator.ofFloat(target,"translationY",-target.getHeight(),30,-10,0)
    );
}
 
Example #22
Source File: MaterialEditText.java    From Social with Apache License 2.0 5 votes vote down vote up
private ObjectAnimator getLabelAnimator() {
  if (labelAnimator == null) {
    labelAnimator = ObjectAnimator.ofFloat(this, "floatingLabelFraction", 0f, 1f);
  }
  labelAnimator.setDuration(floatingLabelAnimating ? 300 : 0);
  return labelAnimator;
}
 
Example #23
Source File: Shake.java    From UltimateAndroid with Apache License 2.0 5 votes vote down vote up
@Override
protected void setupAnimation(View view) {
    getAnimatorSet().playTogether(
            ObjectAnimator.ofFloat(view, "translationX", 0, .10f, -25, .26f, 25,.42f, -25, .58f, 25,.74f,-25,.90f,1,0).setDuration(mDuration)

    );
}
 
Example #24
Source File: ViewAnimationUtils.java    From Jide-Note with MIT License 5 votes vote down vote up
/**
 * Returns an Animator which can animate a clipping circle.
 * <p>
 * Any shadow cast by the View will respect the circular clip from this animator.
 * <p>
 * Only a single non-rectangular clip can be applied on a View at any time.
 * Views clipped by a circular reveal animation take priority over
 * {@link android.view.View#setClipToOutline(boolean) View Outline clipping}.
 * <p>
 * Note that the animation returned here is a one-shot animation. It cannot
 * be re-used, and once started it cannot be paused or resumed.
 *
 * @param view The View will be clipped to the animating circle.
 * @param centerX The x coordinate of the center of the animating circle.
 * @param centerY The y coordinate of the center of the animating circle.
 * @param startRadius The starting radius of the animating circle.
 * @param endRadius The ending radius of the animating circle.
 */
@TargetApi(Build.VERSION_CODES.LOLLIPOP)
public static SupportAnimator createCircularReveal(View view,
                                            int centerX,  int centerY,
                                            float startRadius, float endRadius) {

    if(LOLLIPOP_PLUS){
        return new SupportAnimatorLollipop(android.view.ViewAnimationUtils
                .createCircularReveal(view, centerX, centerY, startRadius, endRadius));
    }

    if(!(view.getParent() instanceof RevealAnimator)){
        throw new IllegalArgumentException("View must be inside RevealFrameLayout or RevealLinearLayout.");
    }

    RevealAnimator revealLayout = (RevealAnimator) view.getParent();
    revealLayout.setTarget(view);
    revealLayout.setCenter(centerX, centerY);

    Rect bounds = new Rect();
    view.getHitRect(bounds);

    ObjectAnimator reveal = ObjectAnimator.ofFloat(revealLayout, "revealRadius", startRadius, endRadius);
    reveal.addListener(getRevealFinishListener(revealLayout, bounds));

    return new SupportAnimatorPreL(reveal);
}
 
Example #25
Source File: MaterialAutoCompleteTextView.java    From Social with Apache License 2.0 5 votes vote down vote up
private ObjectAnimator getLabelAnimator() {
  if (labelAnimator == null) {
    labelAnimator = ObjectAnimator.ofFloat(this, "floatingLabelFraction", 0f, 1f);
  }
  labelAnimator.setDuration(floatingLabelAnimating ? 300 : 0);
  return labelAnimator;
}
 
Example #26
Source File: Switch.java    From Social 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 #27
Source File: Chart.java    From Notification-Analyser with MIT License 5 votes vote down vote up
/**
 * Animates the rendering of the chart on the x-axis with the specified
 * animation time. If animate(...) is called, no further calling of
 * invalidate() is necessary to refresh the chart.
 * 
 * @param durationMillis
 */
public void animateX(int durationMillis) {

    mAnimatorX = ObjectAnimator.ofFloat(this, "phaseX", 0f, 1f);
    mAnimatorX.setDuration(durationMillis);
    mAnimatorX.addUpdateListener(this);
    mAnimatorX.start();
}
 
Example #28
Source File: CoolSwitch.java    From CoolSwitch with Apache License 2.0 5 votes vote down vote up
@Override
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
	setEnabled(false);

	if (hasValidTargetViewIds() && !hasLoadedTargetViews()) {
		disabledView = getRootView().findViewById(disabledViewId);
		enabledView = getRootView().findViewById(enabledViewId);
		animation.setDisabledView(disabledView);
		animation.setEnabledView(enabledView);
	}

	ObjectAnimator.ofFloat(CoolSwitch.this, "animationProgress", 0, 1)
			.setDuration(MOVEMENT_ANIMATION_DURATION_MS)
			.start();
}
 
Example #29
Source File: ViewAnimationUtils.java    From ExpressHelper with GNU General Public License v3.0 5 votes vote down vote up
/**
 * Returns an Animator which can animate a clipping circle.
 * <p>
 * Any shadow cast by the View will respect the circular clip from this animator.
 * <p>
 * Only a single non-rectangular clip can be applied on a View at any time.
 * Views clipped by a circular reveal animation take priority over
 * {@link android.view.View#setClipToOutline(boolean) View Outline clipping}.
 * <p>
 * Note that the animation returned here is a one-shot animation. It cannot
 * be re-used, and once started it cannot be paused or resumed.
 *
 * @param view The View will be clipped to the animating circle.
 * @param centerX The x coordinate of the center of the animating circle.
 * @param centerY The y coordinate of the center of the animating circle.
 * @param startRadius The starting radius of the animating circle.
 * @param endRadius The ending radius of the animating circle.
 */
@TargetApi(Build.VERSION_CODES.LOLLIPOP)
public static SupportAnimator createCircularReveal(View view,
                                            int centerX,  int centerY,
                                            float startRadius, float endRadius) {

    if(LOLLIPOP_PLUS){
        return new SupportAnimatorLollipop(android.view.ViewAnimationUtils
                .createCircularReveal(view, centerX, centerY, startRadius, endRadius));
    }

    if(!(view.getParent() instanceof RevealAnimator)){
        throw new IllegalArgumentException("View must be inside RevealFrameLayout or RevealLinearLayout.");
    }

    RevealAnimator revealLayout = (RevealAnimator) view.getParent();
    revealLayout.setTarget(view);
    revealLayout.setCenter(centerX, centerY);

    Rect bounds = new Rect();
    view.getHitRect(bounds);

    ObjectAnimator reveal = ObjectAnimator.ofFloat(revealLayout, "revealRadius", startRadius, endRadius);
    reveal.addListener(getRevealFinishListener(revealLayout, bounds));

    return new SupportAnimatorPreL(reveal);
}
 
Example #30
Source File: ZoomInRightAnimator.java    From UltimateAndroid with Apache License 2.0 5 votes vote down vote up
@Override
public void prepare(View target) {
    getAnimatorAgent().playTogether(
            ObjectAnimator.ofFloat(target,"scaleX", 0.1f, 0.475f, 1),
            ObjectAnimator.ofFloat(target,"scaleY",0.1f,0.475f,1),
            ObjectAnimator.ofFloat(target,"translationX",target.getWidth() + target.getPaddingRight(),-48,0),
            ObjectAnimator.ofFloat(target,"alpha",0,1,1)
    );
}