use of im.actor.sdk.view.MaterialInterpolator in project actor-platform by actorapp.
the class MediaFullscreenAnimationUtils method animateForward.
public static void animateForward(final View transitionView, float bitmapWidth, float bitmapHeight, int transitionLeft, int transitionTop, int transitionWidth, int transitionHeight, final Animator.AnimatorListener listener) {
transitionView.clearAnimation();
float screenWidth = Screen.getWidth();
float screenHeight = Screen.getHeight() + (Build.VERSION.SDK_INT >= 21 ? Screen.getNavbarHeight() : 0);
if (bitmapHeight > screenHeight || bitmapWidth > screenWidth) {
if (bitmapWidth / screenWidth < bitmapHeight / screenHeight) {
bitmapWidth = bitmapWidth * (screenHeight / bitmapHeight);
bitmapHeight = screenHeight;
} else {
bitmapHeight = bitmapHeight * (screenWidth / bitmapWidth);
bitmapWidth = screenWidth;
}
}
float startScaleWidth = (float) transitionWidth / bitmapWidth;
float startScaleHeight = (float) transitionHeight / bitmapHeight;
/*transitionView.setLeft((int) (transitionLeft + (bitmapWidth * (startScaleWidth - 1) / 2)));
transitionView.setTop((int) (transitionTop + (bitmapHeight * (startScaleHeight - 1) / 2)));
transitionView.setScaleX(startScaleWidth);
transitionView.setScaleY(startScaleHeight);*/
transitionView.animate().setInterpolator(new MaterialInterpolator()).setDuration(0).setStartDelay(0).alpha(1).x(transitionLeft + (bitmapWidth * (startScaleWidth - 1) / 2)).y(transitionTop + (bitmapHeight * (startScaleHeight - 1) / 2)).scaleX(startScaleWidth).scaleY(startScaleHeight).setListener(null).start();
float endScale = 1;
// float endScaleHeight = 1;
float xPadding = 0;
float yPadding = 0;
if (bitmapWidth / screenWidth > bitmapHeight / screenHeight) {
endScale = screenWidth / bitmapWidth;
xPadding = (bitmapWidth * (endScale - 1) / 2);
yPadding = screenHeight / 2 - (bitmapHeight / 2);
} else {
endScale = screenHeight / bitmapHeight;
xPadding = screenWidth / 2 - (bitmapWidth / 2);
yPadding = (bitmapHeight * (endScale - 1)) / 2;
}
final float finalXPadding = xPadding;
final float finalEndScale = endScale;
final float finalYPadding = yPadding;
transitionView.post(new Runnable() {
@Override
public void run() {
transitionView.animate().setInterpolator(new MaterialInterpolator()).setStartDelay(startDelay).setDuration(300 * animationMultiplier).setInterpolator(new MaterialInterpolator()).x(finalXPadding).y(finalYPadding).scaleX(finalEndScale).scaleY(finalEndScale).setListener(listener).start();
}
});
}
use of im.actor.sdk.view.MaterialInterpolator in project actor-platform by actorapp.
the class MediaFullscreenAnimationUtils method animateBack.
public static void animateBack(final View transitionView, float bitmapWidth, float bitmapHeight, final int transitionLeft, final int transitionTop, int transitionWidth, int transitionHeight, final Animator.AnimatorListener listener) {
transitionView.clearAnimation();
float screenWidth = Screen.getWidth();
float screenHeight = Screen.getHeight() + (Build.VERSION.SDK_INT >= 19 ? Screen.getNavbarHeight() : 0);
if (bitmapHeight > screenHeight || bitmapWidth > screenWidth) {
if (bitmapWidth / screenWidth < bitmapHeight / screenHeight) {
bitmapWidth = bitmapWidth * (screenHeight / bitmapHeight);
bitmapHeight = screenHeight;
} else {
bitmapHeight = bitmapHeight * (screenWidth / bitmapWidth);
bitmapWidth = screenWidth;
}
}
final float finishScaleWidth = (float) transitionWidth / bitmapWidth;
final float finishScaleHeight = (float) transitionHeight / bitmapHeight;
float endScale = 1;
// float endScaleHeight = 1;
float xPadding = 0;
float yPadding = 0;
if (bitmapWidth / screenWidth > bitmapHeight / screenHeight) {
endScale = screenWidth / bitmapWidth;
xPadding = (bitmapWidth * (endScale - 1) / 2);
yPadding = screenHeight / 2 - (bitmapHeight / 2);
} else {
endScale = screenHeight / bitmapHeight;
xPadding = screenWidth / 2 - (bitmapWidth / 2);
yPadding = (bitmapHeight * (endScale - 1)) / 2;
}
transitionView.animate().setInterpolator(new MaterialInterpolator()).setStartDelay(0).setDuration(0).setInterpolator(new MaterialInterpolator()).x(xPadding).y(yPadding).scaleX(endScale).scaleY(endScale).setListener(null).start();
final float finalBitmapWidth = bitmapWidth;
final float finalBitmapHeight = bitmapHeight;
final float finalXPadding = xPadding;
final float finalYPadding = yPadding;
transitionView.post(new Runnable() {
@Override
public void run() {
transitionView.animate().setStartDelay(startDelay).setInterpolator(new MaterialInterpolator()).setDuration(300 * animationMultiplier).x(transitionLeft + (finalBitmapWidth * (finishScaleWidth - 1) / 2)).y(transitionTop + (finalBitmapHeight * (finishScaleHeight - 1) / 2)).scaleX(finishScaleWidth).scaleY(finishScaleHeight).setListener(listener).start();
}
});
}
Aggregations