//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Override protected boolean onNestedDirectionFling(Android.Support.Design.Widget.CoordinatorLayout coordinatorLayout, V child, Android.View.View target, float velocityX, float velocityY, boolean consumed, @ScrollDirection int scrollDirection) protected override bool onNestedDirectionFling(CoordinatorLayout coordinatorLayout, V child, View target, float velocityX, float velocityY, bool consumed, ScrollDirection scrollDirection) { // if (consumed) { // handleDirection(child, scrollDirection); // } return(consumed); }
public override void OnDependentViewRemoved(CoordinatorLayout parent, Object child, View dependency) { if (isDependent(dependency)) { updateFabTranslationForBottomNavigationBar(parent, (FloatingActionButton)child, dependency); } }
private void updateSnackBarPosition(CoordinatorLayout parent, V child, View dependency, float translationY) { if (dependency != null && dependency is Snackbar.SnackbarLayout) { ViewCompat.Animate(dependency).SetInterpolator(INTERPOLATOR).SetDuration(80).SetStartDelay(0).TranslationY(translationY).Start(); } }
// @Override // public void onNestedScrollAccepted(CoordinatorLayout coordinatorLayout, V child, View directTargetChild, View target, int nestedScrollAxes) { // super.onNestedScrollAccepted(coordinatorLayout, child, directTargetChild, target, nestedScrollAxes); // } // // @Override // public void onStopNestedScroll(CoordinatorLayout coordinatorLayout, V child, View target) { // super.onStopNestedScroll(coordinatorLayout, child, target); // } public override void OnNestedScroll(CoordinatorLayout coordinatorLayout, Object child, View target, int dxConsumed, int dyConsumed, int dxUnconsumed, int dyUnconsumed) { base.OnNestedScroll(coordinatorLayout, child, target, dxConsumed, dyConsumed, dxUnconsumed, dyUnconsumed); if (dyUnconsumed > 0 && mTotalDyUnconsumed < 0) { mTotalDyUnconsumed = 0; mScrollDirection = ScrollDirection.SCROLL_DIRECTION_UP; onNestedVerticalScrollUnconsumed(coordinatorLayout, (V)child, mScrollDirection, dyConsumed, mTotalDyUnconsumed); } else if (dyUnconsumed < 0 && mTotalDyUnconsumed > 0) { mTotalDyUnconsumed = 0; mScrollDirection = ScrollDirection.SCROLL_DIRECTION_DOWN; onNestedVerticalScrollUnconsumed(coordinatorLayout, (V)child, mScrollDirection, dyConsumed, mTotalDyUnconsumed); } mTotalDyUnconsumed += dyUnconsumed; if (dyConsumed > 0 && mTotalDyConsumed < 0) { mTotalDyConsumed = 0; mConsumedScrollDirection = ScrollDirection.SCROLL_DIRECTION_UP; onNestedVerticalScrollConsumed(coordinatorLayout, (V)child, mConsumedScrollDirection, dyConsumed, mTotalDyConsumed); } else if (dyConsumed < 0 && mTotalDyConsumed > 0) { mTotalDyConsumed = 0; mConsumedScrollDirection = ScrollDirection.SCROLL_DIRECTION_DOWN; onNestedVerticalScrollConsumed(coordinatorLayout, (V)child, mConsumedScrollDirection, dyConsumed, mTotalDyConsumed); } mTotalDyConsumed += dyConsumed; }
public override bool OnLayoutChild(CoordinatorLayout parent, Object child, int layoutDirection) { // First let the parent lay it out parent.OnLayoutChild((FloatingActionButton)child, layoutDirection); updateFabTranslationForBottomNavigationBar(parent, (FloatingActionButton)child, null); return(base.OnLayoutChild(parent, child, layoutDirection)); }
public override bool OnDependentViewChanged(CoordinatorLayout parent, Object child, View dependency) { if (isDependent(dependency)) { updateFabTranslationForBottomNavigationBar(parent, (FloatingActionButton)child, dependency); return(false); } return(base.OnDependentViewChanged(parent, child, dependency)); }
public override bool OnDependentViewChanged(CoordinatorLayout parent, Object child, View dependency) { if (isDependent(dependency)) { updateSnackBarPosition(parent, (V)child, dependency); return(false); } return(base.OnDependentViewChanged(parent, child, dependency)); }
/////////////////////////////////////////////////////////////////////////// // Animating Fab based on Changes /////////////////////////////////////////////////////////////////////////// private void updateFabTranslationForBottomNavigationBar(CoordinatorLayout parent, FloatingActionButton fab, View dependency) { float snackBarTranslation = getFabTranslationYForSnackBar(parent, fab); float[] bottomBarParameters = getFabTranslationYForBottomNavigationBar(parent, fab); float bottomBarTranslation = bottomBarParameters[0]; float bottomBarHeight = bottomBarParameters[1]; float targetTransY = 0; if (snackBarTranslation >= bottomBarTranslation) { // when snackBar is below BottomBar in translation present. targetTransY = bottomBarTranslation; } else { targetTransY = snackBarTranslation; } // if (mFabBehaviour == BottomNavigationBar.FAB_BEHAVIOUR_DISAPPEAR) { // if (targetTransY == 0) { // fab.hide(); // } else { // fab.show(); // } // } //JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final': //ORIGINAL LINE: final float currentTransY = Android.Support.V4.View.ViewCompat.getTranslationY(fab); float currentTransY = ViewCompat.GetTranslationY(fab); // Make sure that any current animation is cancelled ensureOrCancelAnimator(fab); if (fab.IsShown && Math.Abs(currentTransY - targetTransY) > (fab.Height * 0.667f)) { // If the FAB will be travelling by more than 2/3 of it's height, let's animate it instead mFabTranslationYAnimator.TranslationY(targetTransY).Start(); } else { // Now update the translation Y ViewCompat.SetTranslationY(fab, targetTransY); } }
/////////////////////////////////////////////////////////////////////////// // onBottomBar changes /////////////////////////////////////////////////////////////////////////// //JAVA TO C# CONVERTER WARNING: 'final' parameters are not available in .NET: //ORIGINAL LINE: @Override public boolean onLayoutChild(Android.Support.Design.Widget.CoordinatorLayout parent, final V child, int layoutDirection) public override bool OnLayoutChild(CoordinatorLayout parent, Object child, int layoutDirection) { // First let the parent lay it out parent.OnLayoutChild((V)child, layoutDirection); if (child is BottomNavigationBar) { mViewRef = new WeakReference((BottomNavigationBar)child); } ((V)child).Post(() => { mBottomNavHeight = ((V)child).Height; }); updateSnackBarPosition(parent, (V)child, getSnackBarInstance(parent, (V)child)); return(base.OnLayoutChild(parent, child, layoutDirection)); }
public override void OnNestedPreScroll(CoordinatorLayout coordinatorLayout, Object child, View target, int dx, int dy, int[] consumed) { base.OnNestedPreScroll(coordinatorLayout, child, target, dx, dy, consumed); if (dy > 0 && mTotalDy < 0) { mTotalDy = 0; mPreScrollDirection = ScrollDirection.SCROLL_DIRECTION_UP; onNestedVerticalPreScroll(coordinatorLayout, (V)child, target, dx, dy, consumed, mPreScrollDirection); } else if (dy < 0 && mTotalDy > 0) { mTotalDy = 0; mPreScrollDirection = ScrollDirection.SCROLL_DIRECTION_DOWN; onNestedVerticalPreScroll(coordinatorLayout, (V)child, target, dx, dy, consumed, mPreScrollDirection); } mTotalDy += dy; }
private Snackbar.SnackbarLayout getSnackBarInstance(CoordinatorLayout parent, V child) { //JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final': //ORIGINAL LINE: final java.util.List<Android.View.View> dependencies = parent.getDependencies(child); IList <View> dependencies = parent.GetDependencies(child); for (int i = 0, z = dependencies.Count; i < z; i++) { //JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final': //ORIGINAL LINE: final Android.View.View view = dependencies.get(i); View view = dependencies[i]; if (view is Snackbar.SnackbarLayout) { return((Snackbar.SnackbarLayout)view); } } return(null); }
private void handleDirection(CoordinatorLayout parent, V child, ScrollDirection scrollDirection) { BottomNavigationBar bottomNavigationBar = (BottomNavigationBar)mViewRef.Get(); if (bottomNavigationBar != null && bottomNavigationBar.AutoHideEnabled) { if (scrollDirection == ScrollDirection.SCROLL_DIRECTION_DOWN && bottomNavigationBar.Hidden) { updateSnackBarPosition(parent, child, getSnackBarInstance(parent, child), -mBottomNavHeight); bottomNavigationBar.show(); } else if (scrollDirection == ScrollDirection.SCROLL_DIRECTION_UP && !bottomNavigationBar.Hidden) { updateSnackBarPosition(parent, child, getSnackBarInstance(parent, child), 0); bottomNavigationBar.hide(); } } }
private float getFabTranslationYForSnackBar(CoordinatorLayout parent, FloatingActionButton fab) { float minOffset = 0; //JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final': //ORIGINAL LINE: final java.util.List<Android.View.View> dependencies = parent.getDependencies(fab); IList <View> dependencies = parent.GetDependencies(fab); for (int i = 0, z = dependencies.Count; i < z; i++) { //JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final': //ORIGINAL LINE: final Android.View.View view = dependencies.get(i); View view = dependencies[i]; if (view is Snackbar.SnackbarLayout && parent.DoViewsOverlap(fab, view)) { minOffset = Math.Min(minOffset, ViewCompat.GetTranslationY(view) - view.Height); } } return(minOffset); }
/////////////////////////////////////////////////////////////////////////// // Fab Translation due to SnackBar and Due to BottomBar /////////////////////////////////////////////////////////////////////////// private float[] getFabTranslationYForBottomNavigationBar(CoordinatorLayout parent, FloatingActionButton fab) { float minOffset = 0; float viewHeight = 0; //JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final': //ORIGINAL LINE: final java.util.List<Android.View.View> dependencies = parent.getDependencies(fab); IList <View> dependencies = parent.GetDependencies(fab); for (int i = 0, z = dependencies.Count; i < z; i++) { //JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final': //ORIGINAL LINE: final Android.View.View view = dependencies.get(i); View view = dependencies[i]; if (view is BottomNavigationBar) { viewHeight = view.Height; minOffset = Math.Min(minOffset, ViewCompat.GetTranslationY(view) - viewHeight); } } float[] returnValues = new float[] { minOffset, viewHeight }; return(returnValues); }
/// <param name="coordinatorLayout"> the CoordinatorLayout parent of the view this Behavior is /// associated with </param> /// <param name="child"> the child view of the CoordinatorLayout this Behavior is associated with </param> /// <param name="target"> the descendant view of the CoordinatorLayout performing the nested scroll </param> /// <param name="velocityX"> horizontal velocity of the attempted fling </param> /// <param name="velocityY"> vertical velocity of the attempted fling </param> /// <param name="consumed"> true if the nested child view consumed the fling </param> /// <param name="scrollDirection"> Direction of the scroll: SCROLL_DIRECTION_UP, SCROLL_DIRECTION_DOWN </param> /// <returns> true if the Behavior consumed the fling </returns> //JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: protected abstract boolean onNestedDirectionFling(Android.Support.Design.Widget.CoordinatorLayout coordinatorLayout, V child, Android.View.View target, float velocityX, float velocityY, boolean consumed, @ScrollDirection int scrollDirection); protected abstract bool onNestedDirectionFling(CoordinatorLayout coordinatorLayout, V child, View target, float velocityX, float velocityY, bool consumed, ScrollDirection scrollDirection);
/// <param name="coordinatorLayout"> the CoordinatorLayout parent of the view this Behavior is /// associated with </param> /// <param name="child"> the child view of the CoordinatorLayout this Behavior is associated with </param> /// <param name="target"> the descendant view of the CoordinatorLayout performing the nested scroll </param> /// <param name="dx"> the raw horizontal number of pixels that the user attempted to scroll </param> /// <param name="dy"> the raw vertical number of pixels that the user attempted to scroll </param> /// <param name="consumed"> out parameter. consumed[0] should be set to the distance of dx that /// was consumed, consumed[1] should be set to the distance of dy that /// was consumed </param> /// <param name="scrollDirection"> Direction of the scroll: SCROLL_DIRECTION_UP, SCROLL_DIRECTION_DOWN </param> //JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: public abstract void onNestedVerticalPreScroll(Android.Support.Design.Widget.CoordinatorLayout coordinatorLayout, V child, Android.View.View target, int dx, int dy, int[] consumed, @ScrollDirection int scrollDirection); public abstract void onNestedVerticalPreScroll(CoordinatorLayout coordinatorLayout, V child, View target, int dx, int dy, int[] consumed, ScrollDirection scrollDirection);
/// <param name="coordinatorLayout"> the CoordinatorLayout parent of the view this Behavior is /// associated with </param> /// <param name="child"> the child view of the CoordinatorLayout this Behavior is associated with </param> /// <param name="scrollDirection"> Direction of the scroll: SCROLL_DIRECTION_UP, SCROLL_DIRECTION_DOWN </param> /// <param name="currentOverScroll"> Unconsumed value, negative or positive based on the direction; </param> /// <param name="totalConsumedScroll"> Cumulative value for current direction (Unconsumed) </param> //JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: public abstract void onNestedVerticalScrollConsumed(Android.Support.Design.Widget.CoordinatorLayout coordinatorLayout, V child, @ScrollDirection int scrollDirection, int currentOverScroll, int totalConsumedScroll); public abstract void onNestedVerticalScrollConsumed(CoordinatorLayout coordinatorLayout, V child, ScrollDirection scrollDirection, int currentOverScroll, int totalConsumedScroll);
public override bool OnNestedFling(CoordinatorLayout coordinatorLayout, Object child, View target, float velocityX, float velocityY, bool consumed) { base.OnNestedFling(coordinatorLayout, child, target, velocityX, velocityY, consumed); return(onNestedDirectionFling(coordinatorLayout, (V)child, target, velocityX, velocityY, consumed, velocityY > 0 ? ScrollDirection.SCROLL_DIRECTION_UP : ScrollDirection.SCROLL_DIRECTION_DOWN)); }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Override public void onNestedVerticalScrollConsumed(Android.Support.Design.Widget.CoordinatorLayout coordinatorLayout, V child, @ScrollDirection int scrollDirection, int currentOverScroll, int totalConsumedScroll) public override void onNestedVerticalScrollConsumed(CoordinatorLayout coordinatorLayout, V child, ScrollDirection scrollDirection, int currentOverScroll, int totalConsumedScroll) { handleDirection(coordinatorLayout, child, scrollDirection); }
private void updateSnackBarPosition(CoordinatorLayout parent, V child, View dependency) { updateSnackBarPosition(parent, child, dependency, ViewCompat.GetTranslationY(child) - child.Height); }
public override bool OnStartNestedScroll(CoordinatorLayout coordinatorLayout, Object child, View directTargetChild, View target, int nestedScrollAxes) { return((nestedScrollAxes & (int)ScrollAxis.Vertical) != 0); }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Override public void onNestedVerticalPreScroll(Android.Support.Design.Widget.CoordinatorLayout coordinatorLayout, V child, Android.View.View target, int dx, int dy, int[] consumed, @ScrollDirection int scrollDirection) public override void onNestedVerticalPreScroll(CoordinatorLayout coordinatorLayout, V child, View target, int dx, int dy, int[] consumed, ScrollDirection scrollDirection) { // handleDirection(child, scrollDirection); }
/////////////////////////////////////////////////////////////////////////// // Constructor /////////////////////////////////////////////////////////////////////////// // public BottomNavBarFabBehaviour() { // mFabBehaviour = BottomNavigationBar.FAB_BEHAVIOUR_TRANSLATE_AND_STICK; // } /////////////////////////////////////////////////////////////////////////// // Dependencies setup /////////////////////////////////////////////////////////////////////////// public override bool LayoutDependsOn(CoordinatorLayout parent, Object child, View dependency) { return(isDependent(dependency) || base.LayoutDependsOn(parent, child, dependency)); }
/////////////////////////////////////////////////////////////////////////// // Auto Hide Handling /////////////////////////////////////////////////////////////////////////// //JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Override public void onNestedVerticalScrollUnconsumed(Android.Support.Design.Widget.CoordinatorLayout coordinatorLayout, V child, @ScrollDirection int scrollDirection, int currentOverScroll, int totalScroll) public override void onNestedVerticalScrollUnconsumed(CoordinatorLayout coordinatorLayout, V child, ScrollDirection scrollDirection, int currentOverScroll, int totalScroll) { // Empty body }