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