Search in sources :

Example 96 with DecelerateInterpolator

use of android.view.animation.DecelerateInterpolator in project cardslib by gabrielemariotti.

the class BaseActivity method onActionBarAutoShowOrHide.

protected void onActionBarAutoShowOrHide(boolean shown) {
    if (mStatusBarColorAnimator != null) {
        mStatusBarColorAnimator.cancel();
    }
    mStatusBarColorAnimator = ObjectAnimator.ofInt((mDrawerLayout != null) ? mDrawerLayout : mLPreviewUtils, (mDrawerLayout != null) ? "statusBarBackgroundColor" : "statusBarColor", shown ? Color.BLACK : mNormalStatusBarColor, shown ? mNormalStatusBarColor : Color.BLACK).setDuration(250);
    if (mDrawerLayout != null) {
        mStatusBarColorAnimator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {

            @Override
            public void onAnimationUpdate(ValueAnimator valueAnimator) {
                ViewCompat.postInvalidateOnAnimation(mDrawerLayout);
            }
        });
    }
    mStatusBarColorAnimator.setEvaluator(ARGB_EVALUATOR);
    mStatusBarColorAnimator.start();
    for (View view : mHideableHeaderViews) {
        if (shown) {
            view.animate().translationY(0).alpha(1).setDuration(HEADER_HIDE_ANIM_DURATION).setInterpolator(new DecelerateInterpolator());
        } else {
            view.animate().translationY(-view.getBottom()).alpha(0).setDuration(HEADER_HIDE_ANIM_DURATION).setInterpolator(new DecelerateInterpolator());
        }
    }
}
Also used : DecelerateInterpolator(android.view.animation.DecelerateInterpolator) ValueAnimator(android.animation.ValueAnimator) ImageView(android.widget.ImageView) View(android.view.View) TextView(android.widget.TextView)

Example 97 with DecelerateInterpolator

use of android.view.animation.DecelerateInterpolator in project cardslib by gabrielemariotti.

the class BaseActivity method onActionBarAutoShowOrHide.

protected void onActionBarAutoShowOrHide(boolean shown) {
    if (mStatusBarColorAnimator != null) {
        mStatusBarColorAnimator.cancel();
    }
    mStatusBarColorAnimator = ObjectAnimator.ofInt((mDrawerLayout != null) ? mDrawerLayout : mLPreviewUtils, (mDrawerLayout != null) ? "statusBarBackgroundColor" : "statusBarColor", shown ? Color.BLACK : mNormalStatusBarColor, shown ? mNormalStatusBarColor : Color.BLACK).setDuration(250);
    if (mDrawerLayout != null) {
        mStatusBarColorAnimator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {

            @Override
            public void onAnimationUpdate(ValueAnimator valueAnimator) {
                ViewCompat.postInvalidateOnAnimation(mDrawerLayout);
            }
        });
    }
    mStatusBarColorAnimator.setEvaluator(ARGB_EVALUATOR);
    mStatusBarColorAnimator.start();
    for (View view : mHideableHeaderViews) {
        if (shown) {
            view.animate().translationY(0).alpha(1).setDuration(HEADER_HIDE_ANIM_DURATION).setInterpolator(new DecelerateInterpolator());
        } else {
            view.animate().translationY(-view.getBottom()).alpha(0).setDuration(HEADER_HIDE_ANIM_DURATION).setInterpolator(new DecelerateInterpolator());
        }
    }
}
Also used : DecelerateInterpolator(android.view.animation.DecelerateInterpolator) ValueAnimator(android.animation.ValueAnimator) ImageView(android.widget.ImageView) View(android.view.View) TextView(android.widget.TextView)

Example 98 with DecelerateInterpolator

use of android.view.animation.DecelerateInterpolator in project ZoomHeader by githubwing.

the class ZoomHeaderView method expand.

private void expand(float y) {
    mRecyclerView.scrollToPosition(0);
    ValueAnimator va = ValueAnimator.ofFloat(y, -getHeight() / 3);
    va.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {

        @Override
        public void onAnimationUpdate(ValueAnimator animation) {
            float y = (float) animation.getAnimatedValue();
            mViewPager.canScroll = false;
            setTranslationY(y);
            isExpand = true;
        }
    });
    va.setInterpolator(new DecelerateInterpolator());
    va.setDuration(ANIMATE_LENGTH);
    va.start();
    //允许滑动
    ((CtrlLinearLayoutManager) mRecyclerView.getLayoutManager()).setScrollEnabled(true);
    //底部上移
    ValueAnimator bottomAnimate = ValueAnimator.ofFloat(mBottomView.getY(), mBottomY);
    bottomAnimate.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {

        @Override
        public void onAnimationUpdate(ValueAnimator animation) {
            mBottomView.setY((Float) animation.getAnimatedValue());
        }
    });
    bottomAnimate.start();
}
Also used : DecelerateInterpolator(android.view.animation.DecelerateInterpolator) ValueAnimator(android.animation.ValueAnimator)

Example 99 with DecelerateInterpolator

use of android.view.animation.DecelerateInterpolator in project ZoomHeader by githubwing.

the class ZoomHeaderView method restore.

public void restore(float y) {
    mCloseTxt.setAlpha(0f);
    if (y > mFirstY) {
        ValueAnimator closeVa = ValueAnimator.ofFloat(1, 0);
        closeVa.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {

            @Override
            public void onAnimationUpdate(ValueAnimator animation) {
                mCloseTxt.setAlpha((Float) animation.getAnimatedValue());
            }
        });
        closeVa.setDuration(ANIMATE_LENGTH);
        closeVa.start();
    }
    mRecyclerView.scrollToPosition(0);
    ValueAnimator restoreVa = ValueAnimator.ofFloat(y, mFirstY);
    restoreVa.setInterpolator(new DecelerateInterpolator());
    restoreVa.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {

        @Override
        public void onAnimationUpdate(ValueAnimator animation) {
            float y = (float) animation.getAnimatedValue();
            setTranslationY(y);
            isExpand = false;
            mViewPager.canScroll = true;
        }
    });
    restoreVa.setDuration(ANIMATE_LENGTH);
    restoreVa.start();
    //禁止滑动
    ((CtrlLinearLayoutManager) mRecyclerView.getLayoutManager()).setScrollEnabled(false);
    //底部隐藏
    ValueAnimator bottomAnimate = ValueAnimator.ofFloat(mBottomView.getY(), mBottomY + mBottomView.getHeight());
    bottomAnimate.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {

        @Override
        public void onAnimationUpdate(ValueAnimator animation) {
            mBottomView.setY((Float) animation.getAnimatedValue());
        }
    });
    bottomAnimate.start();
}
Also used : DecelerateInterpolator(android.view.animation.DecelerateInterpolator) ValueAnimator(android.animation.ValueAnimator)

Example 100 with DecelerateInterpolator

use of android.view.animation.DecelerateInterpolator in project ListenerMusicPlayer by hefuyicoder.

the class LyricView method doFlingAnimator.

/**
     * 滑行动画
     * @param velocity  滑动速度
     * */
private void doFlingAnimator(float velocity) {
    //注:     Math.abs(velocity)  < =  16000
    // 计算就已当前的滑动速度理论上的滑行距离是多少
    float distance = (velocity / Math.abs(velocity) * Math.min((Math.abs(velocity) * 0.050f), 640));
    // 综合考虑边界问题后得出的实际滑行距离
    float to = Math.min(Math.max(0, (mScrollY - distance)), (mLineCount - 1) * mLineHeight);
    mFlingAnimator = ValueAnimator.ofFloat(mScrollY, to);
    mFlingAnimator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {

        @Override
        public void onAnimationUpdate(ValueAnimator animation) {
            mScrollY = (float) animation.getAnimatedValue();
            measureCurrentLine();
            invalidateView();
        }
    });
    mFlingAnimator.addListener(new AnimatorListenerAdapter() {

        @Override
        public void onAnimationStart(Animator animation) {
            super.onAnimationStart(animation);
            mVelocity = mMinStartUpSpeed - 1;
            mSliding = true;
        }

        @Override
        public void onAnimationEnd(Animator animation) {
            super.onAnimationEnd(animation);
            mSliding = false;
        }

        @Override
        public void onAnimationCancel(Animator animation) {
            super.onAnimationCancel(animation);
        }
    });
    mFlingAnimator.setDuration(420);
    mFlingAnimator.setInterpolator(new DecelerateInterpolator());
    mFlingAnimator.start();
}
Also used : DecelerateInterpolator(android.view.animation.DecelerateInterpolator) Animator(android.animation.Animator) ValueAnimator(android.animation.ValueAnimator) AnimatorListenerAdapter(android.animation.AnimatorListenerAdapter) ValueAnimator(android.animation.ValueAnimator)

Aggregations

DecelerateInterpolator (android.view.animation.DecelerateInterpolator)305 ObjectAnimator (android.animation.ObjectAnimator)77 Animator (android.animation.Animator)65 ValueAnimator (android.animation.ValueAnimator)57 View (android.view.View)57 AccelerateInterpolator (android.view.animation.AccelerateInterpolator)53 AnimatorSet (android.animation.AnimatorSet)52 AnimatorListenerAdapter (android.animation.AnimatorListenerAdapter)36 ImageView (android.widget.ImageView)32 AlphaAnimation (android.view.animation.AlphaAnimation)30 AccelerateDecelerateInterpolator (android.view.animation.AccelerateDecelerateInterpolator)28 Animation (android.view.animation.Animation)21 TextView (android.widget.TextView)20 Point (android.graphics.Point)18 ValueAnimator (com.nineoldandroids.animation.ValueAnimator)18 Paint (android.graphics.Paint)14 LinearInterpolator (android.view.animation.LinearInterpolator)14 ScaleAnimation (android.view.animation.ScaleAnimation)14 AnimatorSet (com.actionbarsherlock.internal.nineoldandroids.animation.AnimatorSet)14 ObjectAnimator (com.actionbarsherlock.internal.nineoldandroids.animation.ObjectAnimator)14