Fixed the animation on the music template by introducing scale

The notification images can now animate in scale.

Change-Id: I7cc90e13f31208c76a490dd94a1ccbc05a4f8bd3
This commit is contained in:
Selim Cinek
2016-01-14 17:04:47 -08:00
parent fa0a2d3d90
commit 3bdbf28b49
2 changed files with 29 additions and 0 deletions

View File

@@ -61,6 +61,11 @@ public class ImageTransformState extends TransformState {
return new ImageTransformState();
}
@Override
protected boolean animateScale() {
return true;
}
@Override
public void recycle() {
super.recycle();

View File

@@ -91,6 +91,24 @@ public class TransformState {
transformedView.setTranslationY(otherPosition[1] - ownStablePosition[1]);
transformedView.animate().translationY(0);
}
if (animateScale()) {
// we also want to animate the scale if we're the same
View otherView = otherState.getTransformedView();
if (otherView.getWidth() != transformedView.getWidth()) {
float scaleX = (otherView.getWidth() * otherView.getScaleX()
/ (float) transformedView.getWidth());
transformedView.setScaleX(scaleX);
transformedView.setPivotX(0);
transformedView.animate().scaleX(1.0f);
}
if (otherView.getHeight() != transformedView.getHeight()) {
float scaleY = (otherView.getHeight() * otherView.getScaleY()
/ (float) transformedView.getHeight());
transformedView.setScaleY(scaleY);
transformedView.setPivotY(0);
transformedView.animate().scaleY(1.0f);
}
}
transformedView.animate()
.setInterpolator(TransformState.FAST_OUT_SLOW_IN)
.setDuration(StackStateAnimator.ANIMATION_DURATION_STANDARD)
@@ -103,6 +121,10 @@ public class TransformState {
setClippingDeactivated(transformedView, true);
}
protected boolean animateScale() {
return false;
}
/**
* Transforms the {@link #mTransformedView} to the given transformviewstate
* @param otherState the state to transform from
@@ -272,6 +294,8 @@ public class TransformState {
if (visible) {
mTransformedView.setTranslationX(0);
mTransformedView.setTranslationY(0);
mTransformedView.setScaleX(1.0f);
mTransformedView.setScaleY(1.0f);
}
}