|
|
@ -3,6 +3,7 @@ package gr.thmmy.mthmmy.utils; |
|
|
|
import android.content.Context; |
|
|
|
import android.support.design.widget.CoordinatorLayout; |
|
|
|
import android.support.design.widget.FloatingActionButton; |
|
|
|
import android.support.v4.view.ViewCompat; |
|
|
|
import android.util.AttributeSet; |
|
|
|
import android.view.View; |
|
|
|
|
|
|
@ -14,7 +15,7 @@ public class ScrollAwareFABBehavior extends CoordinatorLayout.Behavior<FloatingA |
|
|
|
@Override |
|
|
|
public boolean onStartNestedScroll(final CoordinatorLayout coordinatorLayout, final FloatingActionButton child, |
|
|
|
final View directTargetChild, final View target, final int nestedScrollAxes) { |
|
|
|
return true; |
|
|
|
return nestedScrollAxes == ViewCompat.SCROLL_AXIS_VERTICAL; |
|
|
|
} |
|
|
|
|
|
|
|
@Override |
|
|
@ -24,7 +25,13 @@ public class ScrollAwareFABBehavior extends CoordinatorLayout.Behavior<FloatingA |
|
|
|
final int dxUnconsumed, final int dyUnconsumed) { |
|
|
|
super.onNestedScroll(coordinatorLayout, child, target, dxConsumed, dyConsumed,dxUnconsumed, dyUnconsumed); |
|
|
|
if (dyConsumed > 0 && child.getVisibility() == View.VISIBLE) { |
|
|
|
child.hide(); |
|
|
|
child.hide(new FloatingActionButton.OnVisibilityChangedListener() { |
|
|
|
@Override |
|
|
|
public void onHidden(FloatingActionButton fab) { |
|
|
|
super.onHidden(fab); |
|
|
|
fab.setVisibility(View.INVISIBLE); |
|
|
|
} |
|
|
|
}); |
|
|
|
} else if (dyConsumed < 0 && child.getVisibility() != View.VISIBLE) { |
|
|
|
child.show(); |
|
|
|
} |
|
|
|