+ FloatingActionButton.OnVisibilityChangedListener fab_visibility_changed_listener = new FloatingActionButton.OnVisibilityChangedListener() {
+ @Override
+ public void onShown(FloatingActionButton fab) {
+ Log.d("visuals", "FAB shown");
+ super.onShown(fab);
+ if (!fab_should_be_visible) fab.hide();
+ }
+
+ @Override
+ public void onHidden(FloatingActionButton fab) {
+ Log.d("visuals", "FAB hidden");
+ fab.setImageResource(R.drawable.ic_save_white_24dp);
+ fab.setEnabled(true);
+// super.onHidden(fab);
+ if (fab_should_be_visible) fab.show();
+ }
+ };
+
+ private void hide_fab() {
+ hide_fab(false);
+ }
+
+ private void hide_fab(boolean force) {
+ if (!fab_should_be_visible && !force) return;
+
+ fab_should_be_visible = false;
+ fab.hide(fab_visibility_changed_listener);
+ }
+
+ private void show_fab() {
+ show_fab(false);
+ }
+
+ private void show_fab(boolean force) {
+ if (fab_should_be_visible && !force) return;
+
+ fab_should_be_visible = true;
+ fab.show(fab_visibility_changed_listener);
+ }