use of android.animation.ValueAnimator in project android_frameworks_base by DirtyUnicorns.
the class TaskView method updateViewPropertiesToTaskTransform.
void updateViewPropertiesToTaskTransform(TaskViewTransform toTransform, AnimationProps toAnimation, ValueAnimator.AnimatorUpdateListener updateCallback) {
RecentsConfiguration config = Recents.getConfiguration();
cancelTransformAnimation();
// Compose the animations for the transform
mTmpAnimators.clear();
toTransform.applyToTaskView(this, mTmpAnimators, toAnimation, !config.fakeShadows);
if (toAnimation.isImmediate()) {
if (Float.compare(getDimAlpha(), toTransform.dimAlpha) != 0) {
setDimAlpha(toTransform.dimAlpha);
}
if (Float.compare(mViewBounds.getAlpha(), toTransform.viewOutlineAlpha) != 0) {
mViewBounds.setAlpha(toTransform.viewOutlineAlpha);
}
// Manually call back to the animator listener and update callback
if (toAnimation.getListener() != null) {
toAnimation.getListener().onAnimationEnd(null);
}
if (updateCallback != null) {
updateCallback.onAnimationUpdate(null);
}
} else {
// Both the progress and the update are a function of the bounds movement of the task
if (Float.compare(getDimAlpha(), toTransform.dimAlpha) != 0) {
mDimAnimator = ObjectAnimator.ofFloat(this, DIM_ALPHA, getDimAlpha(), toTransform.dimAlpha);
mTmpAnimators.add(toAnimation.apply(AnimationProps.BOUNDS, mDimAnimator));
}
if (Float.compare(mViewBounds.getAlpha(), toTransform.viewOutlineAlpha) != 0) {
mOutlineAnimator = ObjectAnimator.ofFloat(this, VIEW_OUTLINE_ALPHA, mViewBounds.getAlpha(), toTransform.viewOutlineAlpha);
mTmpAnimators.add(toAnimation.apply(AnimationProps.BOUNDS, mOutlineAnimator));
}
if (updateCallback != null) {
ValueAnimator updateCallbackAnim = ValueAnimator.ofInt(0, 1);
updateCallbackAnim.addUpdateListener(updateCallback);
mTmpAnimators.add(toAnimation.apply(AnimationProps.BOUNDS, updateCallbackAnim));
}
// Create the animator
mTransformAnimation = toAnimation.createAnimator(mTmpAnimators);
mTransformAnimation.start();
mTargetAnimationTransform.copyFrom(toTransform);
}
}
use of android.animation.ValueAnimator in project android_frameworks_base by AOSPA.
the class KeyguardAffordanceView method setImageAlpha.
/**
* Sets the alpha of the containing image
*
* @param alpha The new alpha.
* @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 setImageAlpha(float alpha, boolean animate, long duration, Interpolator interpolator, Runnable runnable) {
cancelAnimator(mAlphaAnimator);
alpha = mLaunchingAffordance ? 0 : alpha;
int endAlpha = (int) (alpha * 255);
final Drawable background = getBackground();
if (!animate) {
if (background != null)
background.mutate().setAlpha(endAlpha);
setImageAlpha(endAlpha);
} else {
int currentAlpha = getImageAlpha();
ValueAnimator animator = ValueAnimator.ofInt(currentAlpha, endAlpha);
mAlphaAnimator = animator;
animator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
@Override
public void onAnimationUpdate(ValueAnimator animation) {
int alpha = (int) animation.getAnimatedValue();
if (background != null)
background.mutate().setAlpha(alpha);
setImageAlpha(alpha);
}
});
animator.addListener(mAlphaEndListener);
if (interpolator == null) {
interpolator = alpha == 0.0f ? Interpolators.FAST_OUT_LINEAR_IN : Interpolators.LINEAR_OUT_SLOW_IN;
}
animator.setInterpolator(interpolator);
if (duration == -1) {
float durationFactor = Math.abs(currentAlpha - endAlpha) / 255f;
durationFactor = Math.min(1.0f, durationFactor);
duration = (long) (NORMAL_ANIMATION_DURATION * durationFactor);
}
animator.setDuration(duration);
if (runnable != null) {
animator.addListener(getEndListener(runnable));
}
animator.start();
}
}
use of android.animation.ValueAnimator in project android_frameworks_base by AOSPA.
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();
}
}
}
use of android.animation.ValueAnimator in project android_frameworks_base by AOSPA.
the class PanelView method startUnlockHintAnimationPhase1.
/**
* Phase 1: Move everything upwards.
*/
private void startUnlockHintAnimationPhase1(final Runnable onAnimationFinished) {
float target = Math.max(0, getMaxPanelHeight() - mHintDistance);
ValueAnimator animator = createHeightAnimator(target);
animator.setDuration(250);
animator.setInterpolator(Interpolators.FAST_OUT_SLOW_IN);
animator.addListener(new AnimatorListenerAdapter() {
private boolean mCancelled;
@Override
public void onAnimationCancel(Animator animation) {
mCancelled = true;
}
@Override
public void onAnimationEnd(Animator animation) {
if (mCancelled) {
mHeightAnimator = null;
onAnimationFinished.run();
} else {
startUnlockHintAnimationPhase2(onAnimationFinished);
}
}
});
animator.start();
mHeightAnimator = animator;
mKeyguardBottomArea.getIndicationView().animate().translationY(-mHintDistance).setDuration(250).setInterpolator(Interpolators.FAST_OUT_SLOW_IN).withEndAction(new Runnable() {
@Override
public void run() {
mKeyguardBottomArea.getIndicationView().animate().translationY(0).setDuration(450).setInterpolator(mBounceInterpolator).start();
}
}).start();
}
use of android.animation.ValueAnimator in project android_frameworks_base by AOSPA.
the class PanelView method flingToHeight.
protected void flingToHeight(float vel, boolean expand, float target, float collapseSpeedUpFactor, boolean expandBecauseOfFalsing) {
// Hack to make the expand transition look nice when clear all button is visible - we make
// the animation only to the last notification, and then jump to the maximum panel height so
// clear all just fades in and the decelerating motion is towards the last notification.
final boolean clearAllExpandHack = expand && fullyExpandedClearAllVisible() && mExpandedHeight < getMaxPanelHeight() - getClearAllHeight() && !isClearAllVisible();
if (clearAllExpandHack) {
target = getMaxPanelHeight() - getClearAllHeight();
}
if (target == mExpandedHeight || getOverExpansionAmount() > 0f && expand) {
notifyExpandingFinished();
return;
}
mOverExpandedBeforeFling = getOverExpansionAmount() > 0f;
ValueAnimator animator = createHeightAnimator(target);
if (expand) {
if (expandBecauseOfFalsing) {
vel = 0;
}
mFlingAnimationUtils.apply(animator, mExpandedHeight, target, vel, getHeight());
if (vel == 0) {
animator.setDuration(350);
}
} else {
mFlingAnimationUtils.applyDismissing(animator, mExpandedHeight, target, vel, getHeight());
// Make it shorter if we run a canned animation
if (vel == 0) {
animator.setDuration((long) (animator.getDuration() * getCannedFlingDurationFactor() / collapseSpeedUpFactor));
}
}
if (mPerf != null) {
mPerf.perfLockAcquire(0, mBoostParamVal);
}
animator.addListener(new AnimatorListenerAdapter() {
private boolean mCancelled;
@Override
public void onAnimationCancel(Animator animation) {
if (mPerf != null) {
mPerf.perfLockRelease();
}
mCancelled = true;
}
@Override
public void onAnimationEnd(Animator animation) {
if (mPerf != null) {
mPerf.perfLockRelease();
}
if (clearAllExpandHack && !mCancelled) {
setExpandedHeightInternal(getMaxPanelHeight());
}
mHeightAnimator = null;
if (!mCancelled) {
notifyExpandingFinished();
}
notifyBarPanelExpansionChanged();
}
});
mHeightAnimator = animator;
animator.start();
}
Aggregations