package com.rehivetech.beeeon.gui.view.behavior;

import android.content.Context;
import android.support.design.widget.AppBarLayout;
import android.support.design.widget.CoordinatorLayout;
import android.support.design.widget.Snackbar;
import android.util.AttributeSet;
import android.view.View;

import com.github.clans.fab.FloatingActionMenu;
import com.rehivetech.beeeon.util.Utils;

/**
 * Behavior for Floating action menu
 */
public class FloatingActionMenuBehavior extends CoordinatorLayout.Behavior<FloatingActionMenu> {

	private int mToolbarHeight = -1;

	public FloatingActionMenuBehavior() {
		super();
	}

	public FloatingActionMenuBehavior(Context context, AttributeSet attrs) {
		super(context, attrs);
	}

	@Override
	public boolean layoutDependsOn(CoordinatorLayout parent, FloatingActionMenu child, View dependency) {
		return dependency instanceof Snackbar.SnackbarLayout
				|| dependency instanceof AppBarLayout;
	}

	@Override
	public boolean onDependentViewChanged(CoordinatorLayout parent, FloatingActionMenu fam, View dependency) {
		super.onDependentViewChanged(parent, fam, dependency);

		if (mToolbarHeight == -1) {
			mToolbarHeight = Utils.getToolbarHeight(fam.getContext());
		}

		float translationY;
		if (dependency instanceof Snackbar.SnackbarLayout) {
			translationY = Math.min(0, dependency.getTranslationY() - dependency.getHeight());
		} else {
			CoordinatorLayout.LayoutParams lp = (CoordinatorLayout.LayoutParams) fam
					.getLayoutParams();
			int famBottomMargin = lp.bottomMargin;
			int height;
			if (!fam.isOpened()) {
				height = fam.getChildAt(0).getHeight();
			} else {
				height = fam.getHeight();
			}
			int distanceToScroll = height + famBottomMargin;
			float ratio = (float) dependency.getY() / (float) mToolbarHeight;
			translationY = - distanceToScroll * ratio;
		}
		fam.setTranslationY(translationY);

		return true;
	}

}

@@ -1374,464 +1374,8 @@
 ;%0A%09%09
-%7D else %7B%0A%09%09%09CoordinatorLayout.LayoutParams lp = (CoordinatorLayout.LayoutParams) fam%0A%09%09%09%09%09.getLayoutParams();%0A%09%09%09int famBottomMargin = lp.bottomMargin;%0A%09%09%09int height;%0A%09%09%09if (!fam.isOpened()) %7B%0A%09%09%09%09height = fam.getChildAt(0).getHeight();%0A%09%09%09%7D else %7B%0A%09%09%09%09height = fam.getHeight();%0A%09%09%09%7D%0A%09%09%09int distanceToScroll = height + famBottomMargin;%0A%09%09%09float ratio = (float) dependency.getY() / (float) mToolbarHeight;%0A%09%09%09translationY = - distanceToScroll * ratio;%0A%09%09%7D%0A%09
 %09fam
@@ -1406,16 +1406,19 @@
 tionY);%0A
+%09%09%7D
 %0A%09%09retur

Remove hiding fab in behavior