Java Code Examples for android.support.design.widget.FloatingActionButton#getTag()

The following examples show how to use android.support.design.widget.FloatingActionButton#getTag() . 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: FloatingActionMenu.java    From AppCompat-Extension-Library with Apache License 2.0 6 votes vote down vote up
private void createLabels() {
    Context context = new ContextThemeWrapper(getContext(), mLabelsStyle);

    for (int i = 0; i < mButtonsCount; i++) {
        FloatingActionButton button = (FloatingActionButton) getChildAt(i);
        CharSequence title = button.getContentDescription();

        if (button == mMainButton || title == null ||
                button.getTag(R.id.fab_label) != null) continue;

        LabelView label = new LabelView(context);
        label.setAnimationOffset(mMaxButtonWidth / 2f + mLabelsMargin);
        label.setTextAppearance(getContext(), mLabelsStyle);
        label.setText(title);
        addView(label);

        button.setTag(R.id.fab_label, label);
    }
}
 
Example 2
Source File: ScrollAwareFABBehavior.java    From SteamGifts with MIT License 4 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 (child.getTag() == null) {
        return;
    }

    // try to get the current page, if there's any.
    View view = coordinatorLayout;
    ViewPager viewPager = (ViewPager) coordinatorLayout.findViewById(R.id.viewPager);
    if (viewPager != null && viewPager.getAdapter() instanceof FragmentAdapter) {
        int currentPage = viewPager.getCurrentItem();
        FragmentAdapter pagerAdapter = (FragmentAdapter) viewPager.getAdapter();

        Fragment currentItem = pagerAdapter.getItem(currentPage);

        view = currentItem.getView();
    }

    if (view == null) {
        // We do not have a view we can immediately find.
        child.hide();
        return;
    }

    // Hide if we're over the first item
    RecyclerView recyclerView = (RecyclerView) view.findViewById(R.id.list);
    if (recyclerView != null && recyclerView.getLayoutManager() instanceof LinearLayoutManager) {
        LinearLayoutManager layoutManager = (LinearLayoutManager) recyclerView.getLayoutManager();
        if (layoutManager.findFirstVisibleItemPosition() == 0) {
            child.hide();
        } else if (dyConsumed > 1 && child.getVisibility() == View.VISIBLE)
            child.hide();
        else if (dyConsumed < 1 && child.getVisibility() != View.VISIBLE)
            child.show();
    } else {
        // no recyclerview to attach to?
        child.hide();
    }
}