Java Code Examples for com.google.android.material.floatingactionbutton.FloatingActionButton#hide()

The following examples show how to use com.google.android.material.floatingactionbutton.FloatingActionButton#hide() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: FloatingActionButtonAnimBehavior.java    From MultiTypeRecyclerViewAdapter with Apache License 2.0 6 votes vote down vote up
@Override
    public void onNestedScroll(final CoordinatorLayout coordinatorLayout, final FloatingActionButton child,
                               final View target, final int dxConsumed, final int dyConsumed,
                               final int dxUnconsumed, final int dyUnconsumed) {
        super.onNestedScroll(coordinatorLayout, child, target, dxConsumed, dyConsumed, dxUnconsumed, dyUnconsumed);
        if (dyConsumed > 0 && !this.mIsAnimatingOut && child.getVisibility() == View.VISIBLE) {
            // User scrolled down and the FAB is currently visible -> hide the FAB
//            animateOut(child);
            child.hide(new FloatingActionButton.OnVisibilityChangedListener() {
                @SuppressLint("RestrictedApi")
                @Override
                public void onHidden(FloatingActionButton fab) {
                    fab.setVisibility(View.INVISIBLE);
                }
            });
        } else if (dyConsumed < 0 && child.getVisibility() != View.VISIBLE) {
            // User scrolled up and the FAB is currently not visible -> show the FAB
//            animateIn(child);
            child.show();
        }
    }
 
Example 2
Source File: ScrollAwareFabBehavior.java    From UpdogFarmer with GNU General Public License v3.0 6 votes vote down vote up
@Override
public void onNestedScroll(@NonNull CoordinatorLayout coordinatorLayout, @NonNull FloatingActionButton child,
                           @NonNull View target, int dxConsumed, int dyConsumed, int dxUnconsumed,
                           int dyUnconsumed, int type) {
    super.onNestedScroll(coordinatorLayout, child, target, dxConsumed, dyConsumed, dxUnconsumed, dyUnconsumed, type);

    if (dyConsumed > 0 && child.getVisibility() == View.VISIBLE) {
        child.hide(new FloatingActionButton.OnVisibilityChangedListener() {
            @Override
            public void onHidden(FloatingActionButton fab) {
                // GONE causes it to stop dispatching events...
                fab.setVisibility(View.INVISIBLE);
            }
        });
    } else if (dyConsumed < 0 && child.getVisibility() != View.VISIBLE) {
        child.show();
    }
}
 
Example 3
Source File: ProfileListFragment.java    From SecondScreen with Apache License 2.0 6 votes vote down vote up
@Override
public void onStart() {
    super.onStart();

    LocalBroadcastManager.getInstance(getActivity()).registerReceiver(receiver, filter);

    // Floating action button
    FloatingActionButton floatingActionButton = getActivity().findViewById(R.id.button_floating_action);
    floatingActionButton.setImageResource(R.drawable.ic_action_new);
    if(getActivity().findViewById(R.id.layoutMain).getTag().equals("main-layout-large"))
        floatingActionButton.hide();

    if(getId() == R.id.profileViewEdit) {
        floatingActionButton.show();
        floatingActionButton.setOnClickListener(v -> {
            DialogFragment newProfileFragment = new NewProfileDialogFragment();
            newProfileFragment.show(getFragmentManager(), "new");
        });
    }
}
 
Example 4
Source File: FloatingActionButtonActions.java    From material-components-android with Apache License 2.0 6 votes vote down vote up
public static ViewAction hideThenShow() {
  return new ViewAction() {
    @Override
    public Matcher<View> getConstraints() {
      return isAssignableFrom(FloatingActionButton.class);
    }

    @Override
    public String getDescription() {
      return "Calls hide() then show()";
    }

    @Override
    public void perform(UiController uiController, View view) {
      FloatingActionButton fab = (FloatingActionButton) view;
      fab.hide();
      fab.show();

      long duration = fab.getShowMotionSpec().getTotalDuration();
      uiController.loopMainThreadForAtLeast(duration + 50);
    }
  };
}
 
Example 5
Source File: FloatingActionButtonActions.java    From material-components-android with Apache License 2.0 6 votes vote down vote up
public static ViewAction showThenHide() {
  return new ViewAction() {
    @Override
    public Matcher<View> getConstraints() {
      return isAssignableFrom(FloatingActionButton.class);
    }

    @Override
    public String getDescription() {
      return "Calls show() then hide()";
    }

    @Override
    public void perform(UiController uiController, View view) {
      FloatingActionButton fab = (FloatingActionButton) view;
      fab.show();
      fab.hide();

      long duration = fab.getHideMotionSpec().getTotalDuration();
      uiController.loopMainThreadForAtLeast(duration + 50);
    }
  };
}
 
Example 6
Source File: ScrollAwareFABBehavior.java    From FlexibleAdapter with Apache License 2.0 6 votes vote down vote up
@Override
public void onNestedScroll(@NonNull final CoordinatorLayout coordinatorLayout,
                           @NonNull final FloatingActionButton fab,
                           @NonNull final View target,
                           final int dxConsumed,
                           final int dyConsumed,
                           final int dxUnconsumed,
                           final int dyUnconsumed,
                           final int type) {
    super.onNestedScroll(coordinatorLayout, fab, target, dxConsumed, dyConsumed, dxUnconsumed, dyUnconsumed, type);
    if (!enabled) return;
    if (dyConsumed > 0 && fab.getVisibility() == View.VISIBLE) {
        // User scrolled down and the FAB is currently visible -> hide the FAB
        fab.hide();
    } else if (dyConsumed < 0 && fab.getVisibility() != View.VISIBLE) {
        // User scrolled up and the FAB is currently not visible -> show the FAB
        fab.postDelayed(new Runnable() {
            @Override
            public void run() {
                fab.show();
            }
        }, 200L);
    }
}
 
Example 7
Source File: AppUtils.java    From materialistic with Apache License 2.0 5 votes vote down vote up
public static void toggleFab(FloatingActionButton fab, boolean visible) {
    if (visible) {
        fab.setTag(null);
        fab.show();
    } else {
        fab.setTag(FabAwareScrollBehavior.HIDDEN);
        fab.hide();
    }
}
 
Example 8
Source File: NoteListFragment.java    From Notepad with Apache License 2.0 5 votes vote down vote up
@Override
public void onStart() {
    super.onStart();

    LocalBroadcastManager.getInstance(getActivity()).registerReceiver(receiver, filter);

    // Floating action button
    FloatingActionButton floatingActionButton = getActivity().findViewById(R.id.button_floating_action);
    floatingActionButton.setImageResource(R.drawable.ic_action_new);
    if(getActivity().findViewById(R.id.layoutMain).getTag().equals("main-layout-large"))
        floatingActionButton.hide();

    SharedPreferences prefMain = getActivity().getPreferences(Context.MODE_PRIVATE);

    if(getId() == R.id.noteViewEdit && prefMain.getLong("draft-name", 0) == 0) {
        floatingActionButton.show();
        floatingActionButton.setOnClickListener(v -> {
            ScrollPositions.getInstance().setPosition(listView.getFirstVisiblePosition());
            listener.getCabArray().clear();

            Bundle bundle = new Bundle();
            bundle.putString("filename", "new");

            Fragment fragment = new NoteEditFragment();
            fragment.setArguments(bundle);

            // Add NoteEditFragment
            getFragmentManager()
                .beginTransaction()
                .replace(R.id.noteViewEdit, fragment, "NoteEditFragment")
                .setTransition(FragmentTransaction.TRANSIT_FRAGMENT_CLOSE)
                .commit();
        });
    }
}
 
Example 9
Source File: FABHideOnScrollBehavior.java    From hipda with GNU General Public License v2.0 5 votes vote down vote up
public static void hideFab(FloatingActionButton child) {
    child.hide(new FloatingActionButton.OnVisibilityChangedListener() {
        @Override
        public void onHidden(FloatingActionButton fab) {
            super.onHidden(fab);
            fab.setVisibility(View.INVISIBLE);
        }
    });
}
 
Example 10
Source File: SearchableBaseNoteFragment.java    From nextcloud-notes with GNU General Public License v3.0 5 votes vote down vote up
private void hideSearchFabs() {
    FloatingActionButton next = getSearchNextButton();
    FloatingActionButton prev = getSearchPrevButton();
    if (prev != null) {
        prev.hide();
    }
    if (next != null) {
        next.hide();
    }
}
 
Example 11
Source File: ScrollAwareFABBehavior.java    From Easy_xkcd with Apache License 2.0 5 votes vote down vote up
@Override
public void onNestedScroll(CoordinatorLayout coordinatorLayout, FloatingActionButton child,
                           View target, int dxConsumed, int dyConsumed, int dxUnconsumed, int dyUnconsumed) {
    super.onNestedScroll(coordinatorLayout, child, target, dxConsumed, dyConsumed, dxUnconsumed,
            dyUnconsumed);

    if (dyConsumed > 0 && child.getVisibility() == View.VISIBLE) {
        child.hide();
    } else if (dyConsumed < 0 && child.getVisibility() != View.VISIBLE) {
        child.show();
        child.setVisibility(View.VISIBLE);
    }
}
 
Example 12
Source File: ConditionListFragment.java    From Easer with GNU General Public License v3.0 5 votes vote down vote up
@Override
public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) {
    //noinspection ConstantConditions
    if (LocalSkillRegistry.getInstance().condition().getEnabledSkills(getContext()).size() == 0) {
        FloatingActionButton fab = view.findViewById(R.id.fab);
        fab.hide();
    }
}
 
Example 13
Source File: EventListFragment.java    From Easer with GNU General Public License v3.0 5 votes vote down vote up
@Override
public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) {
    //noinspection ConstantConditions
    if (LocalSkillRegistry.getInstance().event().getEnabledSkills(getContext()).size() == 0) {
        FloatingActionButton fab = view.findViewById(R.id.fab);
        fab.hide();
    }
}
 
Example 14
Source File: ProfileListFragment.java    From Easer with GNU General Public License v3.0 5 votes vote down vote up
@Override
public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) {
    //TODO: Check remote plugins also
    //noinspection ConstantConditions
    if (LocalSkillRegistry.getInstance().operation().getEnabledSkills(getContext()).size() == 0) {
        FloatingActionButton fab = view.findViewById(R.id.fab);
        fab.hide();
    }
}
 
Example 15
Source File: OdysseyMainActivity.java    From odyssey with GNU General Public License v3.0 5 votes vote down vote up
@Override
public void setupFAB(View.OnClickListener listener) {
    FloatingActionButton playButton = findViewById(R.id.odyssey_play_button);

    if (playButton != null) {
        if (listener == null) {
            playButton.hide();
        } else {
            playButton.show();
        }

        playButton.setOnClickListener(listener);
    }
}
 
Example 16
Source File: ScrollAwareFABBehavior.java    From CustomBottomSheetBehavior with Apache License 2.0 5 votes vote down vote up
@Override
public boolean onDependentViewChanged(CoordinatorLayout parent, FloatingActionButton child, View dependency) {
    /**
     * Because we are not moving it, we always return false in this method.
     */

    if (offset == 0)
        setOffsetValue(parent);

    if (mBottomSheetBehaviorRef == null)
        getBottomSheetBehavior(parent);

    int DyFix = getDyBetweenChildAndDependency(child, dependency);

    if ((child.getY() + DyFix) < offset)
        child.hide();
    else if ((child.getY() + DyFix) >= offset) {

        /**
         * We are calculating every time point in Y where BottomSheet get {@link BottomSheetBehaviorGoogleMapsLike#STATE_COLLAPSED}.
         * If PeekHeight change dynamically we can reflect the behavior asap.
         */
        if (mBottomSheetBehaviorRef == null || mBottomSheetBehaviorRef.get() == null)
            getBottomSheetBehavior(parent);
        int collapsedY = dependency.getHeight() - mBottomSheetBehaviorRef.get().getPeekHeight();

        if ((child.getY() + DyFix) > collapsedY)
            child.hide();
        else
            child.show();
    }

    return false;
}
 
Example 17
Source File: NoteListFragment.java    From Notepad with Apache License 2.0 4 votes vote down vote up
public void hideFab() {
    FloatingActionButton floatingActionButton = getActivity().findViewById(R.id.button_floating_action);
    floatingActionButton.hide();
}
 
Example 18
Source File: WelcomeFragment.java    From Notepad with Apache License 2.0 4 votes vote down vote up
public void hideFab() {
    FloatingActionButton floatingActionButton = getActivity().findViewById(R.id.button_floating_action_welcome);
    floatingActionButton.hide();
}
 
Example 19
Source File: FloatingActionButtonBindingAdapter.java    From deagle with Apache License 2.0 4 votes vote down vote up
@BindingAdapter("visible") public static void setVisible(final FloatingActionButton fab, final boolean visible) {
	if (visible) fab.show();
	else fab.hide();
}
 
Example 20
Source File: DynamicFABUtils.java    From dynamic-support with Apache License 2.0 2 votes vote down vote up
/**
 * Same animation that FloatingActionButton.Behavior uses to hide the FAB when the
 * AppBarLayout exits.
 *
 * @param fab The FAB to set hide animation.
 */
public static void hide(@NonNull FloatingActionButton fab) {
    fab.hide();
}