use of android.animation.PropertyValuesHolder in project android_frameworks_base by AOSPA.
the class ScrimController method updateScrim.
private void updateScrim(boolean animate, View scrim, float alpha, float currentAlpha) {
if (mKeyguardFadingOutInProgress) {
return;
}
ValueAnimator previousAnimator = StackStateAnimator.getChildTag(scrim, TAG_KEY_ANIM);
float animEndValue = -1;
if (previousAnimator != null) {
if (animate || alpha == currentAlpha) {
previousAnimator.cancel();
} else {
animEndValue = StackStateAnimator.getChildTag(scrim, TAG_END_ALPHA);
}
}
if (alpha != currentAlpha && alpha != animEndValue) {
if (animate) {
startScrimAnimation(scrim, alpha);
scrim.setTag(TAG_START_ALPHA, currentAlpha);
scrim.setTag(TAG_END_ALPHA, alpha);
} else {
if (previousAnimator != null) {
float previousStartValue = StackStateAnimator.getChildTag(scrim, TAG_START_ALPHA);
float previousEndValue = StackStateAnimator.getChildTag(scrim, TAG_END_ALPHA);
// we need to increase all animation keyframes of the previous animator by the
// relative change to the end value
PropertyValuesHolder[] values = previousAnimator.getValues();
float relativeDiff = alpha - previousEndValue;
float newStartValue = previousStartValue + relativeDiff;
newStartValue = Math.max(0, Math.min(1.0f, newStartValue));
values[0].setFloatValues(newStartValue, alpha);
scrim.setTag(TAG_START_ALPHA, newStartValue);
scrim.setTag(TAG_END_ALPHA, alpha);
previousAnimator.setCurrentPlayTime(previousAnimator.getCurrentPlayTime());
} else {
// update the alpha directly
setCurrentScrimAlpha(scrim, alpha);
updateScrimColor(scrim);
}
}
}
}
use of android.animation.PropertyValuesHolder in project android_frameworks_base by AOSPA.
the class FastScroller method animateBounds.
/**
* Returns an animator for the view's bounds.
*/
private static Animator animateBounds(View v, Rect bounds) {
final PropertyValuesHolder left = PropertyValuesHolder.ofInt(LEFT, bounds.left);
final PropertyValuesHolder top = PropertyValuesHolder.ofInt(TOP, bounds.top);
final PropertyValuesHolder right = PropertyValuesHolder.ofInt(RIGHT, bounds.right);
final PropertyValuesHolder bottom = PropertyValuesHolder.ofInt(BOTTOM, bounds.bottom);
return ObjectAnimator.ofPropertyValuesHolder(v, left, top, right, bottom);
}
use of android.animation.PropertyValuesHolder in project android_frameworks_base by AOSPA.
the class StackView method transformViewAtIndex.
private void transformViewAtIndex(int index, final View view, boolean animate) {
final float maxPerspectiveShiftY = mPerspectiveShiftY;
final float maxPerspectiveShiftX = mPerspectiveShiftX;
if (mStackMode == ITEMS_SLIDE_DOWN) {
index = mMaxNumActiveViews - index - 1;
if (index == mMaxNumActiveViews - 1)
index--;
} else {
index--;
if (index < 0)
index++;
}
float r = (index * 1.0f) / (mMaxNumActiveViews - 2);
final float scale = 1 - PERSPECTIVE_SCALE_FACTOR * (1 - r);
float perspectiveTranslationY = r * maxPerspectiveShiftY;
float scaleShiftCorrectionY = (scale - 1) * (getMeasuredHeight() * (1 - PERSPECTIVE_SHIFT_FACTOR_Y) / 2.0f);
final float transY = perspectiveTranslationY + scaleShiftCorrectionY;
float perspectiveTranslationX = (1 - r) * maxPerspectiveShiftX;
float scaleShiftCorrectionX = (1 - scale) * (getMeasuredWidth() * (1 - PERSPECTIVE_SHIFT_FACTOR_X) / 2.0f);
final float transX = perspectiveTranslationX + scaleShiftCorrectionX;
// this animation so as not to interfere with the new transformation.
if (view instanceof StackFrame) {
((StackFrame) view).cancelTransformAnimator();
}
if (animate) {
PropertyValuesHolder translationX = PropertyValuesHolder.ofFloat("translationX", transX);
PropertyValuesHolder translationY = PropertyValuesHolder.ofFloat("translationY", transY);
PropertyValuesHolder scalePropX = PropertyValuesHolder.ofFloat("scaleX", scale);
PropertyValuesHolder scalePropY = PropertyValuesHolder.ofFloat("scaleY", scale);
ObjectAnimator oa = ObjectAnimator.ofPropertyValuesHolder(view, scalePropX, scalePropY, translationY, translationX);
oa.setDuration(STACK_RELAYOUT_DURATION);
if (view instanceof StackFrame) {
((StackFrame) view).setTransformAnimator(oa);
}
oa.start();
} else {
view.setTranslationX(transX);
view.setTranslationY(transY);
view.setScaleX(scale);
view.setScaleY(scale);
}
}
use of android.animation.PropertyValuesHolder in project android_frameworks_base by AOSPA.
the class NotificationStackScrollLayout method startBottomAnimation.
private void startBottomAnimation() {
int previousStartValue = mStartAnimationRect.bottom;
int previousEndValue = mEndAnimationRect.bottom;
int newEndValue = mBackgroundBounds.bottom;
ObjectAnimator previousAnimator = mBottomAnimator;
if (previousAnimator != null && previousEndValue == newEndValue) {
return;
}
if (!mAnimateNextBackgroundBottom) {
// just a local update was performed
if (previousAnimator != null) {
// we need to increase all animation keyframes of the previous animator by the
// relative change to the end value
PropertyValuesHolder[] values = previousAnimator.getValues();
values[0].setIntValues(previousStartValue, newEndValue);
mStartAnimationRect.bottom = previousStartValue;
mEndAnimationRect.bottom = newEndValue;
previousAnimator.setCurrentPlayTime(previousAnimator.getCurrentPlayTime());
return;
} else {
// no new animation needed, let's just apply the value
setBackgroundBottom(newEndValue);
return;
}
}
if (previousAnimator != null) {
previousAnimator.cancel();
}
ObjectAnimator animator = ObjectAnimator.ofInt(this, "backgroundBottom", mCurrentBounds.bottom, newEndValue);
Interpolator interpolator = Interpolators.FAST_OUT_SLOW_IN;
animator.setInterpolator(interpolator);
animator.setDuration(StackStateAnimator.ANIMATION_DURATION_STANDARD);
// remove the tag when the animation is finished
animator.addListener(new AnimatorListenerAdapter() {
@Override
public void onAnimationEnd(Animator animation) {
mStartAnimationRect.bottom = -1;
mEndAnimationRect.bottom = -1;
mBottomAnimator = null;
}
});
animator.start();
mStartAnimationRect.bottom = mCurrentBounds.bottom;
mEndAnimationRect.bottom = newEndValue;
mBottomAnimator = animator;
}
use of android.animation.PropertyValuesHolder in project android_frameworks_base by DirtyUnicorns.
the class FragmentManagerImpl method modifiesAlpha.
static boolean modifiesAlpha(Animator anim) {
if (anim == null) {
return false;
}
if (anim instanceof ValueAnimator) {
ValueAnimator valueAnim = (ValueAnimator) anim;
PropertyValuesHolder[] values = valueAnim.getValues();
for (int i = 0; i < values.length; i++) {
if (("alpha").equals(values[i].getPropertyName())) {
return true;
}
}
} else if (anim instanceof AnimatorSet) {
List<Animator> animList = ((AnimatorSet) anim).getChildAnimations();
for (int i = 0; i < animList.size(); i++) {
if (modifiesAlpha(animList.get(i))) {
return true;
}
}
}
return false;
}
Aggregations