use of androidx.interpolator.view.animation.FastOutLinearInInterpolator in project Carbon by ZieIony.
the class AnimUtils method getSlideOutAnimator.
public static ValueAnimator getSlideOutAnimator(int gravity) {
ViewAnimator animator = new ViewAnimator();
animator.setInterpolator(new FastOutLinearInInterpolator());
animator.setOnSetupValuesListener(() -> {
View view = animator.getTarget();
int height = view.getMeasuredHeight();
ViewGroup.LayoutParams layoutParams = view.getLayoutParams();
boolean top = (gravity & Gravity.BOTTOM) == Gravity.BOTTOM;
if (layoutParams != null && layoutParams instanceof ViewGroup.MarginLayoutParams)
height += top ? ((ViewGroup.MarginLayoutParams) layoutParams).bottomMargin : ((ViewGroup.MarginLayoutParams) layoutParams).topMargin;
animator.setFloatValues(view.getTranslationY(), top ? height : -height);
long duration = (long) (SHORT_ANIMATION_DURATION * (1 - Math.abs(view.getTranslationY() / height)));
animator.setDuration(duration);
});
animator.addUpdateListener(valueAnimator -> {
View view = animator.getTarget();
view.setTranslationY((Float) valueAnimator.getAnimatedValue());
});
return animator;
}
use of androidx.interpolator.view.animation.FastOutLinearInInterpolator in project Carbon by ZieIony.
the class AnimUtils method getFlyOutAnimator.
public static ValueAnimator getFlyOutAnimator() {
ViewAnimator animator = new ViewAnimator();
animator.setInterpolator(new FastOutLinearInInterpolator());
animator.setOnSetupValuesListener(() -> {
View view = animator.getTarget();
float start = view.getAlpha();
animator.setFloatValues(start, 0);
animator.setDuration((long) (SHORT_ANIMATION_DURATION * start));
});
animator.addUpdateListener(valueAnimator -> {
View view = animator.getTarget();
view.setAlpha((Float) valueAnimator.getAnimatedValue());
view.setTranslationY(Math.min(view.getHeight() / 2, view.getResources().getDimension(R.dimen.carbon_1dip) * 50.0f) * (1 - (Float) valueAnimator.getAnimatedValue()));
});
return animator;
}
use of androidx.interpolator.view.animation.FastOutLinearInInterpolator in project Douya by DreaminginCodeZH.
the class ViewUtils method fadeOut.
public static void fadeOut(@NonNull View view, int duration, boolean gone, @Nullable Runnable nextRunnable) {
if (view.getVisibility() != View.VISIBLE || view.getAlpha() == 0) {
// Cancel any starting animation.
view.animate().alpha(0).setDuration(0).start();
view.setVisibility(gone ? View.GONE : View.INVISIBLE);
if (nextRunnable != null) {
nextRunnable.run();
}
return;
}
view.animate().alpha(0).setDuration(duration).setInterpolator(new FastOutLinearInInterpolator()).setListener(new AnimatorListenerAdapter() {
private boolean mCanceled = false;
@Override
public void onAnimationCancel(@NonNull Animator animator) {
mCanceled = true;
}
@Override
public void onAnimationEnd(@NonNull Animator animator) {
if (!mCanceled) {
view.setVisibility(gone ? View.GONE : View.INVISIBLE);
if (nextRunnable != null) {
nextRunnable.run();
}
}
}
}).start();
}
use of androidx.interpolator.view.animation.FastOutLinearInInterpolator in project Douya by DreaminginCodeZH.
the class ProfileLayout method animateExit.
private void animateExit() {
int offset = getOffset();
int height = getHeight();
if (offset >= height) {
mListener.onExitAnimationEnd();
return;
}
ObjectAnimator animator = ObjectAnimator.ofInt(this, OFFSET, offset, height);
animator.setDuration(mShortAnimationTime);
animator.setInterpolator(new FastOutLinearInInterpolator());
animator.addListener(new AnimatorListenerAdapter() {
@Override
public void onAnimationEnd(Animator animation) {
if (mListener != null) {
mListener.onExitAnimationEnd();
}
}
});
animator.start();
}
use of androidx.interpolator.view.animation.FastOutLinearInInterpolator in project Douya by DreaminginCodeZH.
the class FriendlyFloatingActionButton method hide.
public void hide() {
if (!mShowing) {
return;
}
mShowing = false;
cancelAnimator();
mAnimator = ObjectAnimator.ofFloat(this, TRANSLATION_Y, getTranslationY(), getHideTranslationY()).setDuration(mAnimationDuration);
mAnimator.setInterpolator(new FastOutLinearInInterpolator());
mAnimator.start();
}
Aggregations