|
|
|
@ -18,32 +18,41 @@ public class FabScrollHelper {
|
|
|
|
|
|
|
|
|
|
public void onScroll(int dx, int dy) {
|
|
|
|
|
if (dy > 0 && _fabMenu.getVisibility() == View.VISIBLE && !_isAnimating) {
|
|
|
|
|
_isAnimating = true;
|
|
|
|
|
CoordinatorLayout.LayoutParams lp = (CoordinatorLayout.LayoutParams) _fabMenu.getLayoutParams();
|
|
|
|
|
int fabBottomMargin = lp.bottomMargin;
|
|
|
|
|
setVisible(false);
|
|
|
|
|
} else if (dy < 0 && _fabMenu.getVisibility() != View.VISIBLE && !_isAnimating) {
|
|
|
|
|
setVisible(true);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void setVisible(boolean visible) {
|
|
|
|
|
if (visible) {
|
|
|
|
|
_fabMenu.setVisibility(View.VISIBLE);
|
|
|
|
|
_fabMenu.animate()
|
|
|
|
|
.translationY(_fabMenu.getHeight() + fabBottomMargin)
|
|
|
|
|
.setInterpolator(new AccelerateInterpolator(2))
|
|
|
|
|
.translationY(0)
|
|
|
|
|
.setInterpolator(new DecelerateInterpolator(2))
|
|
|
|
|
.setListener(new AnimatorListenerAdapter() {
|
|
|
|
|
@Override
|
|
|
|
|
public void onAnimationEnd(Animator animation) {
|
|
|
|
|
_isAnimating = false;
|
|
|
|
|
_fabMenu.setVisibility(View.INVISIBLE);
|
|
|
|
|
super.onAnimationEnd(animation);
|
|
|
|
|
}
|
|
|
|
|
}).start();
|
|
|
|
|
} else if (dy < 0 && _fabMenu.getVisibility() != View.VISIBLE && !_isAnimating) {
|
|
|
|
|
_fabMenu.setVisibility(View.VISIBLE);
|
|
|
|
|
} else {
|
|
|
|
|
_isAnimating = true;
|
|
|
|
|
CoordinatorLayout.LayoutParams lp = (CoordinatorLayout.LayoutParams) _fabMenu.getLayoutParams();
|
|
|
|
|
int fabBottomMargin = lp.bottomMargin;
|
|
|
|
|
_fabMenu.animate()
|
|
|
|
|
.translationY(0)
|
|
|
|
|
.setInterpolator(new DecelerateInterpolator(2))
|
|
|
|
|
.translationY(_fabMenu.getHeight() + fabBottomMargin)
|
|
|
|
|
.setInterpolator(new AccelerateInterpolator(2))
|
|
|
|
|
.setListener(new AnimatorListenerAdapter() {
|
|
|
|
|
@Override
|
|
|
|
|
public void onAnimationEnd(Animator animation) {
|
|
|
|
|
_isAnimating = false;
|
|
|
|
|
_fabMenu.setVisibility(View.INVISIBLE);
|
|
|
|
|
super.onAnimationEnd(animation);
|
|
|
|
|
}
|
|
|
|
|
}).start();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|