Search in sources :

Example 11 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 12 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)

Example 13 with ValueAnimator

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

the class SlidingUpBaseActivity method slideWithAnimation.

private void slideWithAnimation(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) {
                slideTo((float) animation.getAnimatedValue(), true);
            }
        });
        animator.start();
    }
}
Also used : ValueAnimator(com.nineoldandroids.animation.ValueAnimator)

Example 14 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 15 with ValueAnimator

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

the class FillGapBaseActivity method changeHeaderBackgroundHeightAnimated.

private void changeHeaderBackgroundHeightAnimated(boolean shouldShowGap, boolean animated) {
    if (mGapIsChanging) {
        return;
    }
    final int heightOnGapShown = mHeaderBar.getHeight();
    final int heightOnGapHidden = mHeaderBar.getHeight() + mActionBarSize;
    final float from = mHeaderBackground.getLayoutParams().height;
    final float to;
    if (shouldShowGap) {
        if (!mGapHidden) {
            // Already shown
            return;
        }
        to = heightOnGapShown;
    } else {
        if (mGapHidden) {
            // Already hidden
            return;
        }
        to = heightOnGapHidden;
    }
    if (animated) {
        ViewPropertyAnimator.animate(mHeaderBackground).cancel();
        ValueAnimator a = ValueAnimator.ofFloat(from, to);
        a.setDuration(100);
        a.setInterpolator(new AccelerateDecelerateInterpolator());
        a.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {

            @Override
            public void onAnimationUpdate(ValueAnimator animation) {
                float height = (float) animation.getAnimatedValue();
                changeHeaderBackgroundHeight(height, to, heightOnGapHidden);
            }
        });
        a.start();
    } else {
        changeHeaderBackgroundHeight(to, to, heightOnGapHidden);
    }
}
Also used : AccelerateDecelerateInterpolator(android.view.animation.AccelerateDecelerateInterpolator) ValueAnimator(com.nineoldandroids.animation.ValueAnimator)

Aggregations

ValueAnimator (com.nineoldandroids.animation.ValueAnimator)105 Animator (com.nineoldandroids.animation.Animator)55 AnimatorListenerAdapter (com.nineoldandroids.animation.AnimatorListenerAdapter)46 StateAnimator (carbon.animation.StateAnimator)30 DecelerateInterpolator (android.view.animation.DecelerateInterpolator)19 View (android.view.View)17 AccelerateDecelerateInterpolator (android.view.animation.AccelerateDecelerateInterpolator)15 Interpolator (android.view.animation.Interpolator)11 Reveal (carbon.internal.Reveal)11 Paint (android.graphics.Paint)7 ObjectAnimator (com.nineoldandroids.animation.ObjectAnimator)6 AccelerateInterpolator (android.view.animation.AccelerateInterpolator)5 RecyclerView (android.support.v7.widget.RecyclerView)4 SimpleItemAnimator (android.support.v7.widget.SimpleItemAnimator)4 FrameLayout (android.widget.FrameLayout)4 ImageView (android.widget.ImageView)4 ArrayList (java.util.ArrayList)4 MotionEvent (android.view.MotionEvent)3 TouchInterceptionFrameLayout (com.github.ksoichiro.android.observablescrollview.TouchInterceptionFrameLayout)3 AnimatorUpdateListener (com.nineoldandroids.animation.ValueAnimator.AnimatorUpdateListener)3