Search in sources :

Example 1 with FloatingActionButton

use of com.github.clans.fab.FloatingActionButton in project cw-omnibus by commonsguy.

the class AsyncDemoFragment method onViewCreated.

@Override
public void onViewCreated(View v, Bundle savedInstanceState) {
    super.onViewCreated(v, savedInstanceState);
    getListView().setScrollbarFadingEnabled(false);
    setListAdapter(adapter);
    FloatingActionButton fab = (FloatingActionButton) v.findViewById(R.id.refresh);
    fab.setOnClickListener(this);
    changeMenuIconAnimation((FloatingActionMenu) v.findViewById(R.id.settings));
}
Also used : FloatingActionButton(com.github.clans.fab.FloatingActionButton)

Example 2 with FloatingActionButton

use of com.github.clans.fab.FloatingActionButton in project FloatingActionButton by Clans.

the class MenusFragment method onViewCreated.

@Override
public void onViewCreated(View view, @Nullable Bundle savedInstanceState) {
    super.onViewCreated(view, savedInstanceState);
    menuRed = (FloatingActionMenu) view.findViewById(R.id.menu_red);
    menuYellow = (FloatingActionMenu) view.findViewById(R.id.menu_yellow);
    menuGreen = (FloatingActionMenu) view.findViewById(R.id.menu_green);
    menuBlue = (FloatingActionMenu) view.findViewById(R.id.menu_blue);
    menuDown = (FloatingActionMenu) view.findViewById(R.id.menu_down);
    menuLabelsRight = (FloatingActionMenu) view.findViewById(R.id.menu_labels_right);
    fab1 = (FloatingActionButton) view.findViewById(R.id.fab1);
    fab2 = (FloatingActionButton) view.findViewById(R.id.fab2);
    fab3 = (FloatingActionButton) view.findViewById(R.id.fab3);
    final FloatingActionButton programFab1 = new FloatingActionButton(getActivity());
    programFab1.setButtonSize(FloatingActionButton.SIZE_MINI);
    programFab1.setLabelText(getString(R.string.lorem_ipsum));
    programFab1.setImageResource(R.drawable.ic_edit);
    menuRed.addMenuButton(programFab1);
    programFab1.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            programFab1.setLabelColors(ContextCompat.getColor(getActivity(), R.color.grey), ContextCompat.getColor(getActivity(), R.color.light_grey), ContextCompat.getColor(getActivity(), R.color.white_transparent));
            programFab1.setLabelTextColor(ContextCompat.getColor(getActivity(), R.color.black));
        }
    });
    ContextThemeWrapper context = new ContextThemeWrapper(getActivity(), R.style.MenuButtonsStyle);
    FloatingActionButton programFab2 = new FloatingActionButton(context);
    programFab2.setLabelText("Programmatically added button");
    programFab2.setImageResource(R.drawable.ic_edit);
    menuYellow.addMenuButton(programFab2);
    fab1.setEnabled(false);
    menuRed.setClosedOnTouchOutside(true);
    menuBlue.setIconAnimated(false);
    menuDown.hideMenuButton(false);
    menuRed.hideMenuButton(false);
    menuYellow.hideMenuButton(false);
    menuGreen.hideMenuButton(false);
    menuBlue.hideMenuButton(false);
    menuLabelsRight.hideMenuButton(false);
    fabEdit = (FloatingActionButton) view.findViewById(R.id.fab_edit);
    fabEdit.setShowAnimation(AnimationUtils.loadAnimation(getActivity(), R.anim.scale_up));
    fabEdit.setHideAnimation(AnimationUtils.loadAnimation(getActivity(), R.anim.scale_down));
}
Also used : ContextThemeWrapper(android.view.ContextThemeWrapper) FloatingActionButton(com.github.clans.fab.FloatingActionButton) View(android.view.View)

Example 3 with FloatingActionButton

use of com.github.clans.fab.FloatingActionButton in project FloatingActionButton by Clans.

the class ProgressFragment method onViewCreated.

@Override
public void onViewCreated(View view, @Nullable Bundle savedInstanceState) {
    super.onViewCreated(view, savedInstanceState);
    Locale[] availableLocales = Locale.getAvailableLocales();
    mProgressTypes = new LinkedList<>();
    for (ProgressType type : ProgressType.values()) {
        mProgressTypes.offer(type);
    }
    final FloatingActionButton fab = (FloatingActionButton) view.findViewById(R.id.fab);
    fab.setMax(mMaxProgress);
    RecyclerView recyclerView = (RecyclerView) view.findViewById(R.id.my_recycler_view);
    recyclerView.setHasFixedSize(true);
    recyclerView.setLayoutManager(new LinearLayoutManager(getActivity()));
    recyclerView.setAdapter(new LanguageAdapter(availableLocales));
    fab.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            ProgressType type = mProgressTypes.poll();
            switch(type) {
                case INDETERMINATE:
                    fab.setShowProgressBackground(true);
                    fab.setIndeterminate(true);
                    mProgressTypes.offer(ProgressType.INDETERMINATE);
                    break;
                case PROGRESS_POSITIVE:
                    fab.setIndeterminate(false);
                    fab.setProgress(70, true);
                    mProgressTypes.offer(ProgressType.PROGRESS_POSITIVE);
                    break;
                case PROGRESS_NEGATIVE:
                    fab.setProgress(30, true);
                    mProgressTypes.offer(ProgressType.PROGRESS_NEGATIVE);
                    break;
                case HIDDEN:
                    fab.hideProgress();
                    mProgressTypes.offer(ProgressType.HIDDEN);
                    break;
                case PROGRESS_NO_ANIMATION:
                    increaseProgress(fab, 0);
                    break;
                case PROGRESS_NO_BACKGROUND:
                    fab.setShowProgressBackground(false);
                    fab.setIndeterminate(true);
                    mProgressTypes.offer(ProgressType.PROGRESS_NO_BACKGROUND);
                    break;
            }
        }
    });
    recyclerView.addOnScrollListener(new RecyclerView.OnScrollListener() {

        @Override
        public void onScrolled(RecyclerView recyclerView, int dx, int dy) {
            super.onScrolled(recyclerView, dx, dy);
            if (Math.abs(dy) > mScrollOffset) {
                if (dy > 0) {
                    fab.hide(true);
                } else {
                    fab.show(true);
                }
            }
        }
    });
}
Also used : Locale(java.util.Locale) LinearLayoutManager(android.support.v7.widget.LinearLayoutManager) RecyclerView(android.support.v7.widget.RecyclerView) TextView(android.widget.TextView) View(android.view.View) FloatingActionButton(com.github.clans.fab.FloatingActionButton) RecyclerView(android.support.v7.widget.RecyclerView)

Example 4 with FloatingActionButton

use of com.github.clans.fab.FloatingActionButton in project Robot-Scouter by SUPERCILEX.

the class ScoutTemplateSheet method initFabMenu.

private void initFabMenu() {
    mFam = mRootView.findViewById(R.id.fab_menu);
    FloatingActionButton header = mRootView.findViewById(R.id.add_header);
    FloatingActionButton checkbox = mRootView.findViewById(R.id.add_checkbox);
    FloatingActionButton stopwatch = mRootView.findViewById(R.id.add_stopwatch);
    FloatingActionButton note = mRootView.findViewById(R.id.add_note);
    FloatingActionButton counter = mRootView.findViewById(R.id.add_counter);
    FloatingActionButton spinner = mRootView.findViewById(R.id.add_spinner);
    header.setOnClickListener(this);
    checkbox.setOnClickListener(this);
    stopwatch.setOnClickListener(this);
    note.setOnClickListener(this);
    counter.setOnClickListener(this);
    spinner.setOnClickListener(this);
    header.setImageResource(R.drawable.ic_title_white_24dp);
    checkbox.setImageResource(R.drawable.ic_done_white_24dp);
    stopwatch.setImageResource(R.drawable.ic_timer_white_24dp);
    note.setImageResource(R.drawable.ic_note_white_24dp);
    counter.setImageResource(R.drawable.ic_count_white_24dp);
    spinner.setImageResource(R.drawable.ic_list_white_24dp);
    // This lets us close the fam when the recyclerview it touched
    mRecyclerView.addOnItemTouchListener(this);
}
Also used : FloatingActionButton(com.github.clans.fab.FloatingActionButton)

Aggregations

FloatingActionButton (com.github.clans.fab.FloatingActionButton)4 View (android.view.View)2 LinearLayoutManager (android.support.v7.widget.LinearLayoutManager)1 RecyclerView (android.support.v7.widget.RecyclerView)1 ContextThemeWrapper (android.view.ContextThemeWrapper)1 TextView (android.widget.TextView)1 Locale (java.util.Locale)1