use of android.animation.ValueAnimator in project android_frameworks_base by ResurrectionRemix.
the class AssistInteractionSession method playAssistAnimation.
private void playAssistAnimation() {
Interpolator linearOutSlowIn = AnimationUtils.loadInterpolator(mBackground.getContext(), android.R.interpolator.linear_out_slow_in);
Interpolator fastOutSlowIn = AnimationUtils.loadInterpolator(mBackground.getContext(), android.R.interpolator.fast_out_slow_in);
mScrim.setAlpha(0f);
mScrim.animate().alpha(1f).setStartDelay(100).setDuration(500);
mBackground.setTranslationY(50 * mDensity);
mBackground.animate().translationY(0).setDuration(300).setInterpolator(linearOutSlowIn);
int centerX = mBackground.getWidth() / 2;
int centerY = (int) (mBackground.getHeight() / 5 * 3.8f);
int radius = (int) Math.sqrt(centerX * centerX + centerY * centerY) + 1;
Animator animator = ViewAnimationUtils.createCircularReveal(mBackground, centerX, centerY, 0, radius);
animator.setDuration(300);
animator.setInterpolator(fastOutSlowIn);
animator.start();
ValueAnimator colorAnim = ValueAnimator.ofArgb(Color.WHITE, 0xffe0e0e0);
colorAnim.setDuration(300);
colorAnim.setInterpolator(fastOutSlowIn);
colorAnim.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
@Override
public void onAnimationUpdate(ValueAnimator animation) {
mBackground.setBackgroundColor((Integer) animation.getAnimatedValue());
}
});
colorAnim.start();
mCard1.setY(mBackground.getHeight());
mCard2.setTranslationY(mCard1.getTranslationY());
mCard1.animate().translationY(0).setDuration(500).setInterpolator(linearOutSlowIn).setStartDelay(100);
mCard2.animate().translationY(0).setInterpolator(linearOutSlowIn).setStartDelay(150).setDuration(500);
mNavbarScrim.setAlpha(0f);
mNavbarScrim.animate().alpha(1f).setDuration(500).setStartDelay(100);
}
use of android.animation.ValueAnimator in project android_frameworks_base by ResurrectionRemix.
the class BatteryMeterDrawable method animateSolidBattery.
public void animateSolidBattery(int level, boolean pluggedIn, boolean charging) {
if (charging) {
if (mAnimator != null)
mAnimator.cancel();
final int defaultAlpha = mLevelDrawable.getAlpha();
mAnimator = ValueAnimator.ofInt(defaultAlpha, 0, defaultAlpha);
mAnimator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
@Override
public void onAnimationUpdate(ValueAnimator animation) {
mLevelDrawable.setAlpha((int) animation.getAnimatedValue());
invalidateSelf();
}
});
mAnimator.addListener(new AnimatorListenerAdapter() {
@Override
public void onAnimationCancel(Animator animation) {
mLevelDrawable.setAlpha(defaultAlpha);
mAnimator = null;
}
@Override
public void onAnimationEnd(Animator animation) {
mLevelDrawable.setAlpha(defaultAlpha);
mAnimator = null;
}
});
mAnimator.setDuration(2000);
mAnimator.start();
}
}
use of android.animation.ValueAnimator in project android_frameworks_base by ResurrectionRemix.
the class BatteryMeterDrawable method animateCircleBattery.
public void animateCircleBattery(int level, boolean pluggedIn, boolean charging) {
if (charging) {
if (mAnimator != null)
mAnimator.cancel();
final int defaultAlpha = mLevelDrawable.getAlpha();
mAnimator = ValueAnimator.ofInt(defaultAlpha, 0, defaultAlpha);
mAnimator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
@Override
public void onAnimationUpdate(ValueAnimator animation) {
mLevelDrawable.setAlpha((int) animation.getAnimatedValue());
invalidateSelf();
}
});
mAnimator.addListener(new AnimatorListenerAdapter() {
@Override
public void onAnimationCancel(Animator animation) {
mLevelDrawable.setAlpha(defaultAlpha);
mAnimator = null;
}
@Override
public void onAnimationEnd(Animator animation) {
mLevelDrawable.setAlpha(defaultAlpha);
mAnimator = null;
}
});
mAnimator.setDuration(2000);
mAnimator.start();
}
}
use of android.animation.ValueAnimator in project android_frameworks_base by ResurrectionRemix.
the class KeyguardAffordanceView method setImageScale.
/**
* Sets the scale of the containing image
*
* @param imageScale The new Scale.
* @param animate Should an animation be performed
* @param duration If animate, whats the duration? When -1 we take the default duration
* @param interpolator If animate, whats the interpolator? When null we take the default
* interpolator.
*/
public void setImageScale(float imageScale, boolean animate, long duration, Interpolator interpolator) {
cancelAnimator(mScaleAnimator);
if (!animate) {
mImageScale = imageScale;
invalidate();
} else {
ValueAnimator animator = ValueAnimator.ofFloat(mImageScale, imageScale);
mScaleAnimator = animator;
animator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
@Override
public void onAnimationUpdate(ValueAnimator animation) {
mImageScale = (float) animation.getAnimatedValue();
invalidate();
}
});
animator.addListener(mScaleEndListener);
if (interpolator == null) {
interpolator = imageScale == 0.0f ? Interpolators.FAST_OUT_LINEAR_IN : Interpolators.LINEAR_OUT_SLOW_IN;
}
animator.setInterpolator(interpolator);
if (duration == -1) {
float durationFactor = Math.abs(mImageScale - imageScale) / (1.0f - MIN_ICON_SCALE_AMOUNT);
durationFactor = Math.min(1.0f, durationFactor);
duration = (long) (NORMAL_ANIMATION_DURATION * durationFactor);
}
animator.setDuration(duration);
animator.start();
}
}
use of android.animation.ValueAnimator in project android_frameworks_base by ResurrectionRemix.
the class KeyguardAffordanceView method setCircleRadius.
private void setCircleRadius(float circleRadius, boolean slowAnimation, boolean noAnimation) {
// Check if we need a new animation
boolean radiusHidden = (mCircleAnimator != null && mCircleWillBeHidden) || (mCircleAnimator == null && mCircleRadius == 0.0f);
boolean nowHidden = circleRadius == 0.0f;
boolean radiusNeedsAnimation = (radiusHidden != nowHidden) && !noAnimation;
if (!radiusNeedsAnimation) {
if (mCircleAnimator == null) {
mCircleRadius = circleRadius;
updateIconColor();
invalidate();
if (nowHidden) {
if (mPreviewView != null) {
mPreviewView.setVisibility(View.INVISIBLE);
}
}
} else if (!mCircleWillBeHidden) {
// We just update the end value
float diff = circleRadius - mMinBackgroundRadius;
PropertyValuesHolder[] values = mCircleAnimator.getValues();
values[0].setFloatValues(mCircleStartValue + diff, circleRadius);
mCircleAnimator.setCurrentPlayTime(mCircleAnimator.getCurrentPlayTime());
}
} else {
cancelAnimator(mCircleAnimator);
cancelAnimator(mPreviewClipper);
ValueAnimator animator = getAnimatorToRadius(circleRadius);
Interpolator interpolator = circleRadius == 0.0f ? Interpolators.FAST_OUT_LINEAR_IN : Interpolators.LINEAR_OUT_SLOW_IN;
animator.setInterpolator(interpolator);
long duration = 250;
if (!slowAnimation) {
float durationFactor = Math.abs(mCircleRadius - circleRadius) / (float) mMinBackgroundRadius;
duration = (long) (CIRCLE_APPEAR_DURATION * durationFactor);
duration = Math.min(duration, CIRCLE_DISAPPEAR_MAX_DURATION);
}
animator.setDuration(duration);
animator.start();
if (mPreviewView != null && mPreviewView.getVisibility() == View.VISIBLE) {
mPreviewView.setVisibility(View.VISIBLE);
mPreviewClipper = ViewAnimationUtils.createCircularReveal(mPreviewView, getLeft() + mCenterX, getTop() + mCenterY, mCircleRadius, circleRadius);
mPreviewClipper.setInterpolator(interpolator);
mPreviewClipper.setDuration(duration);
mPreviewClipper.addListener(mClipEndListener);
mPreviewClipper.addListener(new AnimatorListenerAdapter() {
@Override
public void onAnimationEnd(Animator animation) {
mPreviewView.setVisibility(View.INVISIBLE);
}
});
mPreviewClipper.start();
}
}
}
Aggregations