Search in sources :

Example 1 with FloatingActionButton

use of com.getbase.floatingactionbutton.FloatingActionButton in project Slide by ccrama.

the class ReorderSubreddits method doShowSubs.

public void doShowSubs() {
    subs = new CaseInsensitiveArrayList(UserSubscriptions.getSubscriptions(this));
    recyclerView = (RecyclerView) findViewById(R.id.subslist);
    recyclerView.setLayoutManager(new LinearLayoutManager(this));
    recyclerView.setItemAnimator(null);
    DragSortRecycler dragSortRecycler = new DragSortRecycler();
    dragSortRecycler.setViewHandleId();
    dragSortRecycler.setFloatingAlpha();
    dragSortRecycler.setAutoScrollSpeed();
    dragSortRecycler.setAutoScrollWindow();
    dragSortRecycler.setOnItemMovedListener(new DragSortRecycler.OnItemMovedListener() {

        @Override
        public void onItemMoved(int from, int to) {
            if (to == subs.size()) {
                to -= 1;
            }
            String item = subs.remove(from);
            subs.add(to, item);
            adapter.notifyDataSetChanged();
            CaseInsensitiveArrayList pinned = UserSubscriptions.getPinned();
            if (pinned.contains(item) && pinned.size() != 1) {
                pinned.remove(item);
                if (to > pinned.size()) {
                    to = pinned.size();
                }
                pinned.add(to, item);
                setPinned(pinned);
            }
        }
    });
    dragSortRecycler.setOnDragStateChangedListener(new DragSortRecycler.OnDragStateChangedListener() {

        @Override
        public void onDragStart() {
        }

        @Override
        public void onDragStop() {
        }
    });
    final FloatingActionsMenu fab = (FloatingActionsMenu) findViewById(R.id.add);
    {
        FloatingActionButton collection = (FloatingActionButton) findViewById(R.id.collection);
        Drawable icon = ResourcesCompat.getDrawable(getResources(), R.drawable.collection, null);
        collection.setIconDrawable(icon);
        collection.setOnClickListener(new View.OnClickListener() {

            @Override
            public void onClick(View v) {
                fab.collapse();
                if (UserSubscriptions.multireddits != null && !UserSubscriptions.multireddits.isEmpty()) {
                    new AlertDialogWrapper.Builder(ReorderSubreddits.this).setTitle(R.string.create_or_import_multi).setPositiveButton(R.string.btn_new, new DialogInterface.OnClickListener() {

                        @Override
                        public void onClick(DialogInterface dialog, int which) {
                            doCollection();
                        }
                    }).setNegativeButton(R.string.btn_import_multi, new DialogInterface.OnClickListener() {

                        @Override
                        public void onClick(DialogInterface dialog, int which) {
                            final String[] multis = new String[UserSubscriptions.multireddits.size()];
                            int i = 0;
                            for (MultiReddit m : UserSubscriptions.multireddits) {
                                multis[i] = m.getDisplayName();
                                i++;
                            }
                            MaterialDialog.Builder builder = new MaterialDialog.Builder(ReorderSubreddits.this);
                            builder.title(R.string.reorder_subreddits_title).items(multis).itemsCallbackSingleChoice(-1, new MaterialDialog.ListCallbackSingleChoice() {

                                @Override
                                public boolean onSelection(MaterialDialog dialog, View itemView, int which, CharSequence text) {
                                    String name = multis[which];
                                    MultiReddit r = UserSubscriptions.getMultiredditByDisplayName(name);
                                    StringBuilder b = new StringBuilder();
                                    for (MultiSubreddit s : r.getSubreddits()) {
                                        b.append(s.getDisplayName());
                                        b.append("+");
                                    }
                                    int pos = addSubAlphabetically(MULTI_REDDIT + r.getDisplayName());
                                    UserSubscriptions.setSubNameToProperties(MULTI_REDDIT + r.getDisplayName(), b.toString());
                                    adapter.notifyDataSetChanged();
                                    recyclerView.smoothScrollToPosition(pos);
                                    return false;
                                }
                            }).show();
                        }
                    }).show();
                } else {
                    doCollection();
                }
            }
        });
    }
    {
        FloatingActionButton collection = (FloatingActionButton) findViewById(R.id.sub);
        Drawable icon = ResourcesCompat.getDrawable(getResources(), R.drawable.sub, null);
        collection.setIconDrawable(icon);
        collection.setOnClickListener(new View.OnClickListener() {

            @Override
            public void onClick(View v) {
                fab.collapse();
                MaterialDialog.Builder b = new MaterialDialog.Builder(ReorderSubreddits.this).title(R.string.reorder_add_or_search_subreddit).alwaysCallInputCallback().input(getString(R.string.reorder_subreddit_name), null, false, new MaterialDialog.InputCallback() {

                    @Override
                    public void onInput(MaterialDialog dialog, CharSequence raw) {
                        input = raw.toString();
                    }
                }).positiveText(R.string.btn_add).onPositive(new MaterialDialog.SingleButtonCallback() {

                    @Override
                    public void onClick(MaterialDialog dialog, DialogAction which) {
                        new AsyncGetSubreddit().execute(input);
                    }
                }).negativeText(R.string.btn_cancel).onNegative(new MaterialDialog.SingleButtonCallback() {

                    @Override
                    public void onClick(MaterialDialog dialog, DialogAction which) {
                    }
                });
                b.show();
            }
        });
    }
    {
        FloatingActionButton collection = (FloatingActionButton) findViewById(R.id.domain);
        Drawable icon = ResourcesCompat.getDrawable(getResources(), R.drawable.link, null);
        collection.setIconDrawable(icon);
        collection.setOnClickListener(new View.OnClickListener() {

            @Override
            public void onClick(View v) {
                fab.collapse();
                new MaterialDialog.Builder(ReorderSubreddits.this).title(R.string.reorder_add_domain).alwaysCallInputCallback().input("example.com" + getString(R.string.reorder_domain_placeholder), null, false, new MaterialDialog.InputCallback() {

                    @Override
                    public void onInput(MaterialDialog dialog, CharSequence raw) {
                        input = raw.toString().replaceAll("\\s", // remove whitespace from input
                        "");
                        if (input.contains(".")) {
                            dialog.getActionButton(DialogAction.POSITIVE).setEnabled(true);
                        } else {
                            dialog.getActionButton(DialogAction.POSITIVE).setEnabled(false);
                        }
                    }
                }).positiveText(R.string.btn_add).inputRange(1, 35).onPositive(new MaterialDialog.SingleButtonCallback() {

                    @Override
                    public void onClick(MaterialDialog dialog, DialogAction which) {
                        try {
                            String url = (input);
                            List<String> sortedSubs = UserSubscriptions.sortNoExtras(subs);
                            if (sortedSubs.equals(subs)) {
                                subs.add(url);
                                subs = UserSubscriptions.sortNoExtras(subs);
                                adapter = new CustomAdapter(subs);
                                recyclerView.setAdapter(adapter);
                            } else {
                                int pos = addSubAlphabetically(url);
                                adapter.notifyDataSetChanged();
                                recyclerView.smoothScrollToPosition(pos);
                            }
                        } catch (Exception e) {
                            e.printStackTrace();
                            // todo make this better
                            new AlertDialogWrapper.Builder(ReorderSubreddits.this).setTitle(R.string.reorder_url_err).setMessage(R.string.misc_please_try_again).show();
                        }
                    }
                }).negativeText(R.string.btn_cancel).onNegative(new MaterialDialog.SingleButtonCallback() {

                    @Override
                    public void onClick(MaterialDialog dialog, DialogAction which) {
                    }
                }).show();
            }
        });
    }
    recyclerView.addItemDecoration(dragSortRecycler);
    recyclerView.addOnItemTouchListener(dragSortRecycler);
    recyclerView.addOnScrollListener(dragSortRecycler.getScrollListener());
    dragSortRecycler.setViewHandleId();
    if (subs != null && !subs.isEmpty()) {
        adapter = new CustomAdapter(subs);
        // adapter.setHasStableIds(true);
        recyclerView.setAdapter(adapter);
    } else {
        subs = new CaseInsensitiveArrayList();
    }
    recyclerView.addOnScrollListener(new RecyclerView.OnScrollListener() {

        @Override
        public void onScrolled(RecyclerView recyclerView, int dx, int dy) {
            super.onScrolled(recyclerView, dx, dy);
            if (recyclerView.getScrollState() == RecyclerView.SCROLL_STATE_DRAGGING) {
                diff += dy;
            } else {
                diff = 0;
            }
            if (dy <= 0 && fab.getId() != 0) {
            } else {
                fab.collapse();
            }
        }
    });
}
Also used : DialogInterface(android.content.DialogInterface) MultiSubreddit(net.dean.jraw.models.MultiSubreddit) LinearLayoutManager(android.support.v7.widget.LinearLayoutManager) MultiReddit(net.dean.jraw.models.MultiReddit) FloatingActionButton(com.getbase.floatingactionbutton.FloatingActionButton) MaterialDialog(com.afollestad.materialdialogs.MaterialDialog) FloatingActionsMenu(com.getbase.floatingactionbutton.FloatingActionsMenu) Drawable(android.graphics.drawable.Drawable) CaseInsensitiveArrayList(me.ccrama.redditslide.CaseInsensitiveArrayList) View(android.view.View) TextView(android.widget.TextView) RecyclerView(android.support.v7.widget.RecyclerView) DialogAction(com.afollestad.materialdialogs.DialogAction) RecyclerView(android.support.v7.widget.RecyclerView)

Example 2 with FloatingActionButton

use of com.getbase.floatingactionbutton.FloatingActionButton in project MyJapanese by 54wall.

the class MemoryFragment method initFabMenu.

private void initFabMenu() {
    TextDrawable textQing = TextDrawable.builder().beginConfig().fontSize((int) getContext().getResources().getDimension(R.dimen.memory_item_fab_text_size)).endConfig().buildRound("清", getContext().getResources().getColor(R.color.transparent));
    FloatingActionButton fab_qingyin = new FloatingActionButton(getContext());
    fab_qingyin.setIconDrawable(textQing);
    fab_qingyin.setColorNormal(getContext().getResources().getColor(R.color.green));
    fab_qingyin.setColorPressed(getContext().getResources().getColor(R.color.window));
    fab_qingyin.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            presenter.setDate(Constants.CATEGORY_QINGYIN);
            category = Constants.CATEGORY_QINGYIN;
            hideFabMenu();
        }
    });
    TextDrawable textZhuo = TextDrawable.builder().beginConfig().fontSize((int) getContext().getResources().getDimension(R.dimen.memory_item_fab_text_size)).endConfig().buildRound("浊", getContext().getResources().getColor(R.color.transparent));
    FloatingActionButton fab_zhuoyin = new FloatingActionButton(getContext());
    fab_zhuoyin.setIconDrawable(textZhuo);
    fab_zhuoyin.setColorNormal(getContext().getResources().getColor(R.color.orange));
    fab_zhuoyin.setColorPressed(getContext().getResources().getColor(R.color.window));
    fab_zhuoyin.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            presenter.setDate(Constants.CATEGORY_ZHUOYIN);
            category = Constants.CATEGORY_ZHUOYIN;
            hideFabMenu();
        }
    });
    TextDrawable textAo = TextDrawable.builder().beginConfig().fontSize((int) getContext().getResources().getDimension(R.dimen.memory_item_fab_text_size)).endConfig().buildRound("拗", getContext().getResources().getColor(R.color.transparent));
    FloatingActionButton fab_aoyin = new FloatingActionButton(getContext());
    fab_aoyin.setIconDrawable(textAo);
    fab_aoyin.setColorNormal(getContext().getResources().getColor(R.color.blue));
    fab_aoyin.setColorPressed(getContext().getResources().getColor(R.color.window));
    fab_aoyin.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            presenter.setDate(Constants.CATEGORY_AOYIN);
            category = Constants.CATEGORY_AOYIN;
            hideFabMenu();
        }
    });
    mFabMenu.addButton(fab_qingyin);
    mFabMenu.addButton(fab_zhuoyin);
    mFabMenu.addButton(fab_aoyin);
}
Also used : TextDrawable(com.amulyakhare.textdrawable.TextDrawable) FloatingActionButton(com.getbase.floatingactionbutton.FloatingActionButton) MemoryFragmentView(pri.weiqiang.liyujapanese.mvp.view.memory.MemoryFragmentView) BindView(butterknife.BindView) View(android.view.View) SwipeFlingAdapterView(pri.weiqaing.common.widget.swipecardview.SwipeFlingAdapterView)

Example 3 with FloatingActionButton

use of com.getbase.floatingactionbutton.FloatingActionButton in project instructure-android by instructure.

the class FloatingActionMessageView method build.

public FloatingActionMessageView build() {
    // Create the Send Action Button
    actionSend = new FloatingActionButton(getContext());
    actionSend.setSize(FloatingActionButton.SIZE_MINI);
    actionSend.setColorNormal(getResources().getColor(R.color.courseChartreuse));
    actionSend.setColorDisabled(getResources().getColor(R.color.courseChartreuse));
    actionSend.setColorPressed(getResources().getColor(R.color.courseChartreuseDark));
    final Drawable sendDrawable = CanvasContextColor.getColoredDrawable(getContext(), R.drawable.ic_cv_send_thin_white_fill, getResources().getColor(R.color.white));
    actionSend.setIconDrawable(sendDrawable);
    actionSend.setRotation(0);
    // actionSend.setTitle("Send Reply");
    actionSend.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View v) {
            if (mListener != null) {
                mListener.onSendButtonClicked(composeEditText.getText().toString());
            }
        }
    });
    // Create the Attach Button
    actionAttach = new FloatingActionButton(getContext());
    actionAttach.setSize(FloatingActionButton.SIZE_MINI);
    actionAttach.setColorNormal(getResources().getColor(R.color.courseYellow));
    actionAttach.setColorPressed(getResources().getColor(R.color.courseYellowDark));
    final Drawable attachDrawable = CanvasContextColor.getColoredDrawable(getContext(), R.drawable.ic_cv_attachment_fill, getResources().getColor(R.color.white));
    actionAttach.setIconDrawable(attachDrawable);
    actionAttach.setRotation(0);
    // actionAttach.setTitle("Send with attachment");
    actionAttach.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View v) {
            if (mListener != null) {
                mListener.onAttachButtonClicked();
            }
        }
    });
    // add buttons
    actionsMenu.addButton(actionAttach);
    actionsMenu.addButton(actionSend);
    return this;
}
Also used : Drawable(android.graphics.drawable.Drawable) FloatingActionButton(com.getbase.floatingactionbutton.FloatingActionButton) CardView(android.support.v7.widget.CardView) View(android.view.View)

Example 4 with FloatingActionButton

use of com.getbase.floatingactionbutton.FloatingActionButton in project MyJapanese by 54wall.

the class MemoryFragment method initFabMenu.

private void initFabMenu() {
    TextDrawable textQing = TextDrawable.builder().beginConfig().fontSize((int) getContext().getResources().getDimension(R.dimen.memory_item_fab_text_size)).endConfig().buildRound("清", getContext().getResources().getColor(R.color.transparent));
    FloatingActionButton fab_qingyin = new FloatingActionButton(getContext());
    fab_qingyin.setIconDrawable(textQing);
    fab_qingyin.setColorNormal(getContext().getResources().getColor(R.color.green));
    fab_qingyin.setColorPressed(getContext().getResources().getColor(R.color.window));
    fab_qingyin.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            presenter.setDate(Constants.CATEGORY_QINGYIN);
            category = Constants.CATEGORY_QINGYIN;
            hideFabMenu();
        }
    });
    TextDrawable textZhuo = TextDrawable.builder().beginConfig().fontSize((int) getContext().getResources().getDimension(R.dimen.memory_item_fab_text_size)).endConfig().buildRound("浊", getContext().getResources().getColor(R.color.transparent));
    FloatingActionButton fab_zhuoyin = new FloatingActionButton(getContext());
    fab_zhuoyin.setIconDrawable(textZhuo);
    fab_zhuoyin.setColorNormal(getContext().getResources().getColor(R.color.orange));
    fab_zhuoyin.setColorPressed(getContext().getResources().getColor(R.color.window));
    fab_zhuoyin.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            presenter.setDate(Constants.CATEGORY_ZHUOYIN);
            category = Constants.CATEGORY_ZHUOYIN;
            hideFabMenu();
        }
    });
    TextDrawable textAo = TextDrawable.builder().beginConfig().fontSize((int) getContext().getResources().getDimension(R.dimen.memory_item_fab_text_size)).endConfig().buildRound("拗", getContext().getResources().getColor(R.color.transparent));
    FloatingActionButton fab_aoyin = new FloatingActionButton(getContext());
    fab_aoyin.setIconDrawable(textAo);
    fab_aoyin.setColorNormal(getContext().getResources().getColor(R.color.blue));
    fab_aoyin.setColorPressed(getContext().getResources().getColor(R.color.window));
    fab_aoyin.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            presenter.setDate(Constants.CATEGORY_AOYIN);
            category = Constants.CATEGORY_AOYIN;
            hideFabMenu();
        }
    });
    mFabMenu.addButton(fab_qingyin);
    mFabMenu.addButton(fab_zhuoyin);
    mFabMenu.addButton(fab_aoyin);
}
Also used : TextDrawable(com.amulyakhare.textdrawable.TextDrawable) FloatingActionButton(com.getbase.floatingactionbutton.FloatingActionButton) SwipeFlingAdapterView(pri.weiqiang.myjapanese.widget.swipecardview.SwipeFlingAdapterView) BindView(butterknife.BindView) View(android.view.View) BaseView(pri.weiqiang.myjapanese.mvp.view.BaseView)

Example 5 with FloatingActionButton

use of com.getbase.floatingactionbutton.FloatingActionButton in project android-floating-action-button by futuresimple.

the class MainActivity method onCreate.

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);
    findViewById(R.id.pink_icon).setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View v) {
            Toast.makeText(MainActivity.this, "Clicked pink Floating Action Button", Toast.LENGTH_SHORT).show();
        }
    });
    FloatingActionButton button = (FloatingActionButton) findViewById(R.id.setter);
    button.setSize(FloatingActionButton.SIZE_MINI);
    button.setColorNormalResId(R.color.pink);
    button.setColorPressedResId(R.color.pink_pressed);
    button.setIcon(R.drawable.ic_fab_star);
    button.setStrokeVisible(false);
    final View actionB = findViewById(R.id.action_b);
    FloatingActionButton actionC = new FloatingActionButton(getBaseContext());
    actionC.setTitle("Hide/Show Action above");
    actionC.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View v) {
            actionB.setVisibility(actionB.getVisibility() == View.GONE ? View.VISIBLE : View.GONE);
        }
    });
    final FloatingActionsMenu menuMultipleActions = (FloatingActionsMenu) findViewById(R.id.multiple_actions);
    menuMultipleActions.addButton(actionC);
    final FloatingActionButton removeAction = (FloatingActionButton) findViewById(R.id.button_remove);
    removeAction.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View v) {
            ((FloatingActionsMenu) findViewById(R.id.multiple_actions_down)).removeButton(removeAction);
        }
    });
    ShapeDrawable drawable = new ShapeDrawable(new OvalShape());
    drawable.getPaint().setColor(getResources().getColor(R.color.white));
    ((FloatingActionButton) findViewById(R.id.setter_drawable)).setIconDrawable(drawable);
    final FloatingActionButton actionA = (FloatingActionButton) findViewById(R.id.action_a);
    actionA.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View view) {
            actionA.setTitle("Action A clicked");
        }
    });
    // Test that FAMs containing FABs with visibility GONE do not cause crashes
    findViewById(R.id.button_gone).setVisibility(View.GONE);
    final FloatingActionButton actionEnable = (FloatingActionButton) findViewById(R.id.action_enable);
    actionEnable.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View view) {
            menuMultipleActions.setEnabled(!menuMultipleActions.isEnabled());
        }
    });
    FloatingActionsMenu rightLabels = (FloatingActionsMenu) findViewById(R.id.right_labels);
    FloatingActionButton addedOnce = new FloatingActionButton(this);
    addedOnce.setTitle("Added once");
    rightLabels.addButton(addedOnce);
    FloatingActionButton addedTwice = new FloatingActionButton(this);
    addedTwice.setTitle("Added twice");
    rightLabels.addButton(addedTwice);
    rightLabels.removeButton(addedTwice);
    rightLabels.addButton(addedTwice);
}
Also used : FloatingActionsMenu(com.getbase.floatingactionbutton.FloatingActionsMenu) OnClickListener(android.view.View.OnClickListener) FloatingActionButton(com.getbase.floatingactionbutton.FloatingActionButton) ShapeDrawable(android.graphics.drawable.ShapeDrawable) OvalShape(android.graphics.drawable.shapes.OvalShape) View(android.view.View)

Aggregations

View (android.view.View)6 FloatingActionButton (com.getbase.floatingactionbutton.FloatingActionButton)6 BindView (butterknife.BindView)3 TextDrawable (com.amulyakhare.textdrawable.TextDrawable)3 Drawable (android.graphics.drawable.Drawable)2 FloatingActionsMenu (com.getbase.floatingactionbutton.FloatingActionsMenu)2 SwipeFlingAdapterView (pri.weiqaing.common.widget.swipecardview.SwipeFlingAdapterView)2 MemoryFragmentView (pri.weiqiang.liyujapanese.mvp.view.memory.MemoryFragmentView)2 DialogInterface (android.content.DialogInterface)1 ShapeDrawable (android.graphics.drawable.ShapeDrawable)1 OvalShape (android.graphics.drawable.shapes.OvalShape)1 CardView (android.support.v7.widget.CardView)1 LinearLayoutManager (android.support.v7.widget.LinearLayoutManager)1 RecyclerView (android.support.v7.widget.RecyclerView)1 OnClickListener (android.view.View.OnClickListener)1 TextView (android.widget.TextView)1 DialogAction (com.afollestad.materialdialogs.DialogAction)1 MaterialDialog (com.afollestad.materialdialogs.MaterialDialog)1 CaseInsensitiveArrayList (me.ccrama.redditslide.CaseInsensitiveArrayList)1 MultiReddit (net.dean.jraw.models.MultiReddit)1