diff --git a/app/src/main/java/com/wireguard/android/widget/fab/FloatingActionButtonBehavior.java b/app/src/main/java/com/wireguard/android/widget/fab/FloatingActionButtonBehavior.java index c41687b0..ff2adf5a 100644 --- a/app/src/main/java/com/wireguard/android/widget/fab/FloatingActionButtonBehavior.java +++ b/app/src/main/java/com/wireguard/android/widget/fab/FloatingActionButtonBehavior.java @@ -6,13 +6,19 @@ package com.wireguard.android.widget.fab; +import android.animation.Animator; +import android.animation.AnimatorListenerAdapter; +import android.animation.TimeInterpolator; +import android.animation.ValueAnimator; import android.content.Context; import android.support.design.widget.CoordinatorLayout; import android.support.design.widget.Snackbar; +import android.support.v4.view.animation.FastOutSlowInInterpolator; import android.util.AttributeSet; import android.view.View; public class FloatingActionButtonBehavior extends CoordinatorLayout.Behavior { + public FloatingActionButtonBehavior(final Context context, final AttributeSet attrs) { super(context, attrs); } @@ -23,17 +29,39 @@ public class FloatingActionButtonBehavior extends CoordinatorLayout.Behavior child.setBehaviorYTranslation((float)a.getAnimatedValue())); + animator.start(); + } + @Override public boolean onDependentViewChanged(final CoordinatorLayout parent, final FloatingActionsMenu child, final View dependency) { - child.setBehaviorYTranslation(Math.min(0, dependency.getTranslationY() - dependency.getMeasuredHeight())); + animateChange(child, Math.min(0, dependency.getTranslationY() - dependency.getMeasuredHeight()), dependency.getMeasuredHeight()); return true; } @Override - public void onDependentViewRemoved(final CoordinatorLayout parent, FloatingActionsMenu child, + public void onDependentViewRemoved(final CoordinatorLayout parent, final FloatingActionsMenu child, final View dependency) { - // TODO(msf): animate this so it isn't so dramatic when the snackbar is swiped away - child.setBehaviorYTranslation(0); + animateChange(child, 0, dependency.getMeasuredHeight()); } }