use of android.animation.ValueAnimator in project android_frameworks_base by DirtyUnicorns.
the class NotificationPanelView method startQsSizeChangeAnimation.
private void startQsSizeChangeAnimation(int oldHeight, final int newHeight) {
if (mQsSizeChangeAnimator != null) {
oldHeight = (int) mQsSizeChangeAnimator.getAnimatedValue();
mQsSizeChangeAnimator.cancel();
}
mQsSizeChangeAnimator = ValueAnimator.ofInt(oldHeight, newHeight);
mQsSizeChangeAnimator.setDuration(300);
mQsSizeChangeAnimator.setInterpolator(Interpolators.FAST_OUT_SLOW_IN);
mQsSizeChangeAnimator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
@Override
public void onAnimationUpdate(ValueAnimator animation) {
requestScrollerTopPaddingUpdate(false);
requestPanelHeightUpdate();
int height = (int) mQsSizeChangeAnimator.getAnimatedValue();
mQsContainer.setHeightOverride(height);
}
});
mQsSizeChangeAnimator.addListener(new AnimatorListenerAdapter() {
@Override
public void onAnimationEnd(Animator animation) {
mQsSizeChangeAnimator = null;
}
});
mQsSizeChangeAnimator.start();
}
use of android.animation.ValueAnimator in project android_frameworks_base by DirtyUnicorns.
the class StopMotionVectorDrawable method setCurrentFraction.
/**
* {@see android.animation.ValueAnimator#setCurrentFraction}
* @param fraction The fraction to which the animation is advanced or rewound. Values outside
* the range of 0 to the maximum fraction for the animator will be clamped to
* the correct range.
*/
public void setCurrentFraction(float fraction) {
if (mDrawable == null || mAnimatorSet == null)
return;
ArrayList<Animator> animators = mAnimatorSet.getChildAnimations();
for (Animator animator : animators) {
if (animator instanceof ValueAnimator) {
((ValueAnimator) animator).setCurrentFraction(fraction);
}
}
mDrawable.invalidateSelf();
}
use of android.animation.ValueAnimator in project android_frameworks_base by DirtyUnicorns.
the class KeyguardAffordanceHelper method fling.
private void fling(float vel, final boolean snapBack, boolean right) {
float target = right ? -mCallback.getMaxTranslationDistance() : mCallback.getMaxTranslationDistance();
target = snapBack ? 0 : target;
ValueAnimator animator = ValueAnimator.ofFloat(mTranslation, target);
mFlingAnimationUtils.apply(animator, mTranslation, target, vel);
animator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
@Override
public void onAnimationUpdate(ValueAnimator animation) {
mTranslation = (float) animation.getAnimatedValue();
}
});
animator.addListener(mFlingEndListener);
if (!snapBack) {
startFinishingCircleAnimation(vel * 0.375f, mAnimationEndRunnable, right);
mCallback.onAnimationToSideStarted(right, mTranslation, vel);
} else {
reset(true);
}
animator.start();
mSwipeAnimator = animator;
if (snapBack) {
mCallback.onSwipingAborted();
}
}
use of android.animation.ValueAnimator in project android_frameworks_base by DirtyUnicorns.
the class ViewTransformationHelper method transformTo.
@Override
public void transformTo(final TransformableView notification, final Runnable endRunnable) {
if (mViewTransformationAnimation != null) {
mViewTransformationAnimation.cancel();
}
mViewTransformationAnimation = ValueAnimator.ofFloat(0.0f, 1.0f);
mViewTransformationAnimation.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
@Override
public void onAnimationUpdate(ValueAnimator animation) {
transformTo(notification, animation.getAnimatedFraction());
}
});
mViewTransformationAnimation.setInterpolator(Interpolators.LINEAR);
mViewTransformationAnimation.setDuration(StackStateAnimator.ANIMATION_DURATION_STANDARD);
mViewTransformationAnimation.addListener(new AnimatorListenerAdapter() {
public boolean mCancelled;
@Override
public void onAnimationEnd(Animator animation) {
if (!mCancelled) {
if (endRunnable != null) {
endRunnable.run();
}
setVisible(false);
} else {
abortTransformations();
}
}
@Override
public void onAnimationCancel(Animator animation) {
mCancelled = true;
}
});
mViewTransformationAnimation.start();
}
use of android.animation.ValueAnimator in project android_frameworks_base by DirtyUnicorns.
the class NotificationSettingsIconRow method fadeInSettings.
public void fadeInSettings(final boolean fromLeft, final float transX, final float notiThreshold) {
if (mDismissing || mAnimating) {
return;
}
if (isIconLocationChange(transX)) {
setGearAlpha(0f);
}
setIconLocation(transX > 0);
mFadeAnimator = ValueAnimator.ofFloat(mGearIcon.getAlpha(), 1);
mFadeAnimator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
@Override
public void onAnimationUpdate(ValueAnimator animation) {
final float absTrans = Math.abs(transX);
boolean pastGear = (fromLeft && transX <= notiThreshold) || (!fromLeft && absTrans <= notiThreshold);
if (pastGear && !mSettingsFadedIn) {
setGearAlpha((float) animation.getAnimatedValue());
}
}
});
mFadeAnimator.addListener(new AnimatorListenerAdapter() {
@Override
public void onAnimationStart(Animator animation) {
mAnimating = true;
}
@Override
public void onAnimationCancel(Animator animation) {
// TODO should animate back to 0f from current alpha
mGearIcon.setAlpha(0f);
}
@Override
public void onAnimationEnd(Animator animation) {
mAnimating = false;
mSettingsFadedIn = mGearIcon.getAlpha() == 1;
}
});
mFadeAnimator.setInterpolator(Interpolators.ALPHA_IN);
mFadeAnimator.setDuration(GEAR_ALPHA_ANIM_DURATION);
mFadeAnimator.start();
}
Aggregations