Search in sources :

Example 1 with ValueAnimator

use of com.nineoldandroids.animation.ValueAnimator in project cw-omnibus by commonsguy.

the class MainActivity method onCreate.

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);
    word = (TextView) findViewById(R.id.word);
    ValueAnimator positionAnim = ObjectAnimator.ofInt(this, "wordPosition", 0, 24);
    positionAnim.setDuration(12500);
    positionAnim.setRepeatCount(ValueAnimator.INFINITE);
    positionAnim.setRepeatMode(ValueAnimator.RESTART);
    positionAnim.start();
}
Also used : ValueAnimator(com.nineoldandroids.animation.ValueAnimator)

Example 2 with ValueAnimator

use of com.nineoldandroids.animation.ValueAnimator in project cw-omnibus by commonsguy.

the class ViewPropertyAnimatorHC method startAnimation.

/**
     * Starts the underlying Animator for a set of properties. We use a single animator that
     * simply runs from 0 to 1, and then use that fractional value to set each property
     * value accordingly.
     */
private void startAnimation() {
    ValueAnimator animator = ValueAnimator.ofFloat(1.0f);
    ArrayList<NameValuesHolder> nameValueList = (ArrayList<NameValuesHolder>) mPendingAnimations.clone();
    mPendingAnimations.clear();
    int propertyMask = 0;
    int propertyCount = nameValueList.size();
    for (int i = 0; i < propertyCount; ++i) {
        NameValuesHolder nameValuesHolder = nameValueList.get(i);
        propertyMask |= nameValuesHolder.mNameConstant;
    }
    mAnimatorMap.put(animator, new PropertyBundle(propertyMask, nameValueList));
    animator.addUpdateListener(mAnimatorEventListener);
    animator.addListener(mAnimatorEventListener);
    if (mStartDelaySet) {
        animator.setStartDelay(mStartDelay);
    }
    if (mDurationSet) {
        animator.setDuration(mDuration);
    }
    if (mInterpolatorSet) {
        animator.setInterpolator(mInterpolator);
    }
    animator.start();
}
Also used : ArrayList(java.util.ArrayList) ValueAnimator(com.nineoldandroids.animation.ValueAnimator)

Example 3 with ValueAnimator

use of com.nineoldandroids.animation.ValueAnimator in project cw-omnibus by commonsguy.

the class ViewPropertyAnimatorPreHC method startAnimation.

/**
     * Starts the underlying Animator for a set of properties. We use a single animator that
     * simply runs from 0 to 1, and then use that fractional value to set each property
     * value accordingly.
     */
private void startAnimation() {
    ValueAnimator animator = ValueAnimator.ofFloat(1.0f);
    ArrayList<NameValuesHolder> nameValueList = (ArrayList<NameValuesHolder>) mPendingAnimations.clone();
    mPendingAnimations.clear();
    int propertyMask = 0;
    int propertyCount = nameValueList.size();
    for (int i = 0; i < propertyCount; ++i) {
        NameValuesHolder nameValuesHolder = nameValueList.get(i);
        propertyMask |= nameValuesHolder.mNameConstant;
    }
    mAnimatorMap.put(animator, new PropertyBundle(propertyMask, nameValueList));
    animator.addUpdateListener(mAnimatorEventListener);
    animator.addListener(mAnimatorEventListener);
    if (mStartDelaySet) {
        animator.setStartDelay(mStartDelay);
    }
    if (mDurationSet) {
        animator.setDuration(mDuration);
    }
    if (mInterpolatorSet) {
        animator.setInterpolator(mInterpolator);
    }
    animator.start();
}
Also used : ArrayList(java.util.ArrayList) ValueAnimator(com.nineoldandroids.animation.ValueAnimator)

Example 4 with ValueAnimator

use of com.nineoldandroids.animation.ValueAnimator in project Android-ObservableScrollView by ksoichiro.

the class ViewPagerTab2Activity method animateToolbar.

private void animateToolbar(final float toY) {
    float layoutTranslationY = ViewHelper.getTranslationY(mInterceptionLayout);
    if (layoutTranslationY != toY) {
        ValueAnimator animator = ValueAnimator.ofFloat(ViewHelper.getTranslationY(mInterceptionLayout), toY).setDuration(200);
        animator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {

            @Override
            public void onAnimationUpdate(ValueAnimator animation) {
                float translationY = (float) animation.getAnimatedValue();
                ViewHelper.setTranslationY(mInterceptionLayout, translationY);
                if (translationY < 0) {
                    FrameLayout.LayoutParams lp = (FrameLayout.LayoutParams) mInterceptionLayout.getLayoutParams();
                    lp.height = (int) (-translationY + getScreenHeight());
                    mInterceptionLayout.requestLayout();
                }
            }
        });
        animator.start();
    }
}
Also used : FrameLayout(android.widget.FrameLayout) TouchInterceptionFrameLayout(com.github.ksoichiro.android.observablescrollview.TouchInterceptionFrameLayout) ValueAnimator(com.nineoldandroids.animation.ValueAnimator)

Example 5 with ValueAnimator

use of com.nineoldandroids.animation.ValueAnimator in project Android-ObservableScrollView by ksoichiro.

the class SlidingUpBaseActivity method changeHeaderBarColorAnimated.

private void changeHeaderBarColorAnimated(boolean animated) {
    if (mHeaderColorIsChanging) {
        return;
    }
    boolean shouldBeWhite = getAnchorYBottom() == ViewHelper.getTranslationY(mInterceptionLayout);
    if (!mHeaderIsAtBottom && !mHeaderColorChangedToBottom && shouldBeWhite) {
        mHeaderIsAtBottom = true;
        mHeaderIsNotAtBottom = false;
        if (animated) {
            ValueAnimator animator = ValueAnimator.ofFloat(0, 1).setDuration(100);
            animator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {

                @Override
                public void onAnimationUpdate(ValueAnimator animation) {
                    float alpha = (float) animation.getAnimatedValue();
                    mHeaderColorIsChanging = (alpha != 1);
                    changeHeaderBarColor(alpha);
                }
            });
            animator.start();
        } else {
            changeHeaderBarColor(1);
        }
    } else if (!mHeaderIsNotAtBottom && !shouldBeWhite) {
        mHeaderIsAtBottom = false;
        mHeaderIsNotAtBottom = true;
        if (animated) {
            ValueAnimator animator = ValueAnimator.ofFloat(1, 0).setDuration(100);
            animator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {

                @Override
                public void onAnimationUpdate(ValueAnimator animation) {
                    float alpha = (float) animation.getAnimatedValue();
                    mHeaderColorIsChanging = (alpha != 0);
                    changeHeaderBarColor(alpha);
                }
            });
            animator.start();
        } else {
            changeHeaderBarColor(0);
        }
    }
}
Also used : ValueAnimator(com.nineoldandroids.animation.ValueAnimator)

Aggregations

ValueAnimator (com.nineoldandroids.animation.ValueAnimator)123 Animator (com.nineoldandroids.animation.Animator)55 AnimatorListenerAdapter (com.nineoldandroids.animation.AnimatorListenerAdapter)45 StateAnimator (carbon.animation.StateAnimator)28 Paint (android.graphics.Paint)19 DecelerateInterpolator (android.view.animation.DecelerateInterpolator)16 AccelerateDecelerateInterpolator (android.view.animation.AccelerateDecelerateInterpolator)15 View (android.view.View)14 LinearInterpolator (android.view.animation.LinearInterpolator)12 Interpolator (android.view.animation.Interpolator)11 Reveal (carbon.internal.Reveal)11 RecyclerView (android.support.v7.widget.RecyclerView)5 SimpleItemAnimator (android.support.v7.widget.SimpleItemAnimator)4 AccelerateInterpolator (android.view.animation.AccelerateInterpolator)4 FrameLayout (android.widget.FrameLayout)4 ImageView (android.widget.ImageView)4 ObjectAnimator (com.nineoldandroids.animation.ObjectAnimator)4 PropertyValuesHolder (com.nineoldandroids.animation.PropertyValuesHolder)4 AnimatorUpdateListener (com.nineoldandroids.animation.ValueAnimator.AnimatorUpdateListener)4 ArrayList (java.util.ArrayList)4