Search in sources :

Example 1 with FloatingActionMenu

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

the class MenusFragment method onActivityCreated.

@Override
public void onActivityCreated(@Nullable Bundle savedInstanceState) {
    super.onActivityCreated(savedInstanceState);
    menus.add(menuDown);
    menus.add(menuRed);
    menus.add(menuYellow);
    menus.add(menuGreen);
    menus.add(menuBlue);
    menus.add(menuLabelsRight);
    menuYellow.setOnMenuToggleListener(new FloatingActionMenu.OnMenuToggleListener() {

        @Override
        public void onMenuToggle(boolean opened) {
            String text;
            if (opened) {
                text = "Menu opened";
            } else {
                text = "Menu closed";
            }
            Toast.makeText(getActivity(), text, Toast.LENGTH_SHORT).show();
        }
    });
    fab1.setOnClickListener(clickListener);
    fab2.setOnClickListener(clickListener);
    fab3.setOnClickListener(clickListener);
    int delay = 400;
    for (final FloatingActionMenu menu : menus) {
        mUiHandler.postDelayed(new Runnable() {

            @Override
            public void run() {
                menu.showMenuButton(true);
            }
        }, delay);
        delay += 150;
    }
    new Handler().postDelayed(new Runnable() {

        @Override
        public void run() {
            fabEdit.show(true);
        }
    }, delay + 150);
    menuRed.setOnMenuButtonClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            if (menuRed.isOpened()) {
                Toast.makeText(getActivity(), menuRed.getMenuButtonLabelText(), Toast.LENGTH_SHORT).show();
            }
            menuRed.toggle(true);
        }
    });
    createCustomAnimation();
}
Also used : Handler(android.os.Handler) View(android.view.View) FloatingActionMenu(com.github.clans.fab.FloatingActionMenu)

Example 2 with FloatingActionMenu

use of com.github.clans.fab.FloatingActionMenu in project Remindy by abicelis.

the class TaskFragment method onCreateView.

@Nullable
@Override
public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
    View rootView = inflater.inflate(R.layout.fragment_task, container, false);
    //Grab task argument
    if (getArguments().containsKey(TASK_ARGUMENT)) {
        mTask = (Task) getArguments().get(TASK_ARGUMENT);
    } else {
        BaseTransientBottomBar.BaseCallback<Snackbar> callback = new BaseTransientBottomBar.BaseCallback<Snackbar>() {

            @Override
            public void onDismissed(Snackbar transientBottomBar, int event) {
                super.onDismissed(transientBottomBar, event);
                getActivity().setResult(RESULT_CANCELED);
                getActivity().finish();
            }
        };
        Log.e(TAG, "Missing TASK_ARGUMENT argument in TaskFragment.");
        SnackbarUtil.showSnackbar(mContainer, SnackbarUtil.SnackbarType.ERROR, R.string.error_unexpected, SnackbarUtil.SnackbarDuration.LONG, callback);
    }
    mHeaderBasicInfo = (RelativeLayout) rootView.findViewById(R.id.fragment_task_header_basic_info);
    ((TextView) mHeaderBasicInfo.findViewById(R.id.item_task_header_title)).setText(R.string.fragment_task_header_basic_info);
    mHeaderAttachments = (RelativeLayout) rootView.findViewById(R.id.fragment_task_header_attachments);
    ((TextView) mHeaderAttachments.findViewById(R.id.item_task_header_title)).setText(R.string.fragment_task_header_attachments);
    mContainer = (RelativeLayout) rootView.findViewById(R.id.fragment_task_container);
    mContainerBasicInfo = (LinearLayout) rootView.findViewById(R.id.fragment_task_basic_info_container);
    mTaskTitle = (TextView) rootView.findViewById(R.id.fragment_task_title);
    mTaskTitle.setOnFocusChangeListener(new View.OnFocusChangeListener() {

        @Override
        public void onFocusChange(View v, boolean hasFocus) {
            if (hasFocus) {
                mAttachmentsFabMenu.close(true);
            }
        }
    });
    mTaskDescription = (TextView) rootView.findViewById(R.id.fragment_task_description);
    mTaskDescription.setOnFocusChangeListener(new View.OnFocusChangeListener() {

        @Override
        public void onFocusChange(View v, boolean hasFocus) {
            if (hasFocus) {
                mAttachmentsFabMenu.close(true);
            }
        }
    });
    mTaskCategory = (Spinner) rootView.findViewById(R.id.fragment_task_category);
    mAttachmentsFabHint = (TextView) rootView.findViewById(R.id.fragment_task_add_attachment_hint);
    if (mTask.getAttachments().size() == 0) {
        mAttachmentsFabHint.setVisibility(View.VISIBLE);
        mAddAttachmentHintVisible = true;
    } else {
        fadeInHeaders();
        mHeadersVisible = true;
    }
    mAttachmentsFabMenu = (FloatingActionMenu) rootView.findViewById(R.id.fragment_task_add_attachment);
    mAttachmentsFabMenu.setOnMenuToggleListener(new FloatingActionMenu.OnMenuToggleListener() {

        @Override
        public void onMenuToggle(boolean opened) {
            //Hide keyboard
            ((InputMethodManager) getActivity().getSystemService(Context.INPUT_METHOD_SERVICE)).hideSoftInputFromWindow(mContainer.getWindowToken(), 0);
            if (mAddAttachmentHintVisible) {
                //Slide out FAB hint
                TransitionManager.beginDelayedTransition(mContainer, new Slide(Gravity.START));
                mAttachmentsFabHint.setVisibility(View.INVISIBLE);
            }
        }
    });
    mAttachmentsFabList = (FloatingActionButton) rootView.findViewById(R.id.fragment_task_add_list_attachment);
    mAttachmentsFabText = (FloatingActionButton) rootView.findViewById(R.id.fragment_task_add_text_attachment);
    mAttachmentsFabLink = (FloatingActionButton) rootView.findViewById(R.id.fragment_task_add_link_attachment);
    mAttachmentsFabImage = (FloatingActionButton) rootView.findViewById(R.id.fragment_task_add_image_attachment);
    mAttachmentsFabAudio = (FloatingActionButton) rootView.findViewById(R.id.fragment_task_add_audio_attachment);
    mAttachmentsFabList.setOnClickListener(this);
    mAttachmentsFabText.setOnClickListener(this);
    mAttachmentsFabLink.setOnClickListener(this);
    mAttachmentsFabImage.setOnClickListener(this);
    mAttachmentsFabAudio.setOnClickListener(this);
    //Hide keyboard
    ((InputMethodManager) getActivity().getSystemService(Context.INPUT_METHOD_SERVICE)).hideSoftInputFromWindow(mContainer.getWindowToken(), 0);
    mRecyclerView = (RecyclerView) rootView.findViewById(R.id.fragment_task_recycler);
    mNoItemsContainer = (RelativeLayout) rootView.findViewById(R.id.fragment_task_no_items_container);
    setUpRecyclerView();
    setupSpinners();
    setTaskValues();
    return rootView;
}
Also used : BaseTransientBottomBar(android.support.design.widget.BaseTransientBottomBar) InputMethodManager(android.view.inputmethod.InputMethodManager) View(android.view.View) RecyclerView(android.support.v7.widget.RecyclerView) TextView(android.widget.TextView) FloatingActionMenu(com.github.clans.fab.FloatingActionMenu) Slide(com.transitionseverywhere.Slide) TextView(android.widget.TextView) Snackbar(android.support.design.widget.Snackbar) Nullable(android.support.annotation.Nullable)

Aggregations

View (android.view.View)2 FloatingActionMenu (com.github.clans.fab.FloatingActionMenu)2 Handler (android.os.Handler)1 Nullable (android.support.annotation.Nullable)1 BaseTransientBottomBar (android.support.design.widget.BaseTransientBottomBar)1 Snackbar (android.support.design.widget.Snackbar)1 RecyclerView (android.support.v7.widget.RecyclerView)1 InputMethodManager (android.view.inputmethod.InputMethodManager)1 TextView (android.widget.TextView)1 Slide (com.transitionseverywhere.Slide)1