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());
}
}
}
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());
}
}
}
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();
}
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();
}
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();
}
Aggregations