com.getbase.floatingactionbutton.FloatingActionsMenu Java Examples

The following examples show how to use com.getbase.floatingactionbutton.FloatingActionsMenu. 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: FabMenuManager.java    From timecat with Apache License 2.0 6 votes vote down vote up
public FabMenuManager(FloatingActionButton fab, FloatingActionsMenu fabMenu, LeftDrawerManager drawerMgr, MainActivity a) {
    this.fab = fab;
    this.fabMenu = fabMenu;
    this.activity = a;
    this.drawerMgr = drawerMgr;
    this.scheduleActions = getScheduleActions();

    final SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(activity.getApplicationContext());

    fabMenu.setOnFloatingActionsMenuUpdateListener(new FloatingActionsMenu.OnFloatingActionsMenuUpdateListener() {
        @Override
        public void onMenuExpanded() {
            if (!prefs.getBoolean("PREFERENCE_SCHEDULE_HELP_SHOWN", false)) {
                activity.launchActivityDelayed(SchedulesHelpActivity.class, 600);
            }
        }

        @Override
        public void onMenuCollapsed() {

        }
    });

}
 
Example #2
Source File: FloatActionButtonScrollDetectorHelper.java    From talk-android with MIT License 6 votes vote down vote up
@Override
public void onScrollUp() {
    new Handler().post(new Runnable() {
        @Override
        public void run() {
            if (floatActionButton instanceof FloatingActionsMenu) {
                if (((FloatingActionsMenu) floatActionButton).isExpanded()) {
                    ((FloatingActionsMenu) floatActionButton).collapse();
                }
            }
        }
    });
    hide();
    if (mScrollDirectionListener != null) {
        mScrollDirectionListener.onScrollUp();
    }
}
 
Example #3
Source File: FloatActionButtonScrollDetectorHelper.java    From talk-android with MIT License 6 votes vote down vote up
@Override
public void onScrollUp() {
    new Handler().post(new Runnable() {
        @Override
        public void run() {
            if (floatActionButton instanceof FloatingActionsMenu) {
                if (((FloatingActionsMenu) floatActionButton).isExpanded()) {
                    ((FloatingActionsMenu) floatActionButton).collapse();
                }
            }
        }
    });
    hide();
    if (mScrollDirectionListener != null) {
        mScrollDirectionListener.onScrollUp();
    }
}
 
Example #4
Source File: MainActivity.java    From pe-protector-moe with GNU General Public License v3.0 5 votes vote down vote up
@Override
public void onClick(View v) {
    FloatingActionsMenu floatingActionsMenu = findViewById(R.id.multiple_actions);
    switch (v.getId()) {
        case R.id.action_add_task:
            Log.i(TAG, "[UI] 开启任务界面");
            floatingActionsMenu.collapse();
            Intent intent = new Intent(MainActivity.this, HtmlActivity.class);
            intent.putExtra("type", HtmlActivity.HTML_TASK);
            startActivityForResult(intent, HtmlActivity.REQUEST_CODE);
            break;
        case R.id.action_set_task:
            Log.i(TAG, "[UI] 开启路径界面");
            floatingActionsMenu.collapse();
            Intent intent2 = new Intent(MainActivity.this, HtmlActivity.class);
            intent2.putExtra("type", HtmlActivity.HTML_TASK_MANAGER);
            startActivity(intent2);
            break;
        case R.id.action_setting:
            Log.i(TAG, "[UI] 开启设置界面");
            floatingActionsMenu.collapse();
            Intent intent3 = new Intent(MainActivity.this, HtmlActivity.class);
            intent3.putExtra("type", HtmlActivity.HTML_SETTING);
            startActivity(intent3);
            break;
    }
}
 
Example #5
Source File: FloatingActionsMenuBehavior.java    From Aria2App with GNU General Public License v3.0 5 votes vote down vote up
@Nullable
private static FloatingActionButton findInnerMenu(@NonNull FloatingActionsMenu menu) {
    for (int i = 0; i < menu.getChildCount(); i++) {
        View v = menu.getChildAt(i);
        if (v instanceof AddFloatingActionButton)
            return (AddFloatingActionButton) v;
    }

    return null;
}
 
Example #6
Source File: FloatingActionsMenuBehavior.java    From Aria2App with GNU General Public License v3.0 5 votes vote down vote up
@Override
public void onNestedScroll(@NonNull CoordinatorLayout coordinatorLayout, @NonNull FloatingActionsMenu child, @NonNull View target, int dxConsumed, int dyConsumed, int dxUnconsumed, int dyUnconsumed, int type, @NonNull int[] consumed) {
    mTotalDy = dyConsumed < 0 && mTotalDy > 0 || dyConsumed > 0 && mTotalDy < 0 ? 0 : mTotalDy;
    if (mTotalDy == 0) ViewCompat.animate(child).cancel();
    mTotalDy += dyConsumed;

    int totalHeight = child.getHeight();
    if (mTotalDy > totalHeight && isScaleMax(child)) {
        scaleTo(child, false);
    } else if (mTotalDy < 0 && Math.abs(mTotalDy) >= totalHeight && !isScaleMax(child)) {
        scaleTo(child, true);
    }
}
 
Example #7
Source File: FloatingActionsMenuBehavior.java    From Aria2App with GNU General Public License v3.0 5 votes vote down vote up
@Override
public boolean onNestedPreFling(@NonNull CoordinatorLayout coordinatorLayout, @NonNull final FloatingActionsMenu child, @NonNull View target, float velocityX, float velocityY) {
    if (Math.abs(velocityY) < Math.abs(velocityX)) return false;

    if (velocityY < 0) {
        /* Velocity is negative, we are flinging up */
        scaleTo(child, true);
    } else if (velocityY > 0) {
        /* Velocity is positive, we are flinging down */
        if (child.isExpanded()) {
            child.collapse();
            child.setOnFloatingActionsMenuUpdateListener(new FloatingActionsMenu.OnFloatingActionsMenuUpdateListener() {
                @Override
                public void onMenuExpanded() {
                }

                @Override
                public void onMenuCollapsed() {
                    if (isScaleMax(child))
                        scaleTo(child, false);
                }
            });
        } else {
            if (isScaleMax(child)) scaleTo(child, false);
        }
    }

    return super.onNestedPreFling(coordinatorLayout, child, target, velocityX, velocityY);
}
 
Example #8
Source File: ScrollAwareFamBehavior.java    From NGA-CLIENT-VER-OPEN-SOURCE with GNU General Public License v2.0 5 votes vote down vote up
public void onNestedScroll(CoordinatorLayout coordinatorLayout, FloatingActionsMenu child, View target, int dxConsumed, int dyConsumed, int dxUnconsumed, int dyUnconsumed) {
    if (dyConsumed > 10 && !this.mIsAnimatingOut && this.mIsShown) {
        child.collapse();
        animateOut(child);
    } else if (dyConsumed < -10 && !this.mIsAnimationIn && !this.mIsShown) {
        animateIn(child);
    }

}
 
Example #9
Source File: ArticleTabFragment.java    From NGA-CLIENT-VER-OPEN-SOURCE with GNU General Public License v2.0 5 votes vote down vote up
private void updateFloatingMenu() {
    CoordinatorLayout.LayoutParams lp = (CoordinatorLayout.LayoutParams) mFam.getLayoutParams();
    mBehavior = (ScrollAwareFamBehavior) lp.getBehavior();
    if (mConfig.isLeftHandMode()) {
        lp.gravity = Gravity.START | Gravity.BOTTOM;
        mFam.setExpandDirection(FloatingActionsMenu.EXPAND_UP, FloatingActionsMenu.LABELS_ON_RIGHT_SIDE);
        mFam.setLayoutParams(lp);
    }
}
 
Example #10
Source File: TopicListFragment.java    From NGA-CLIENT-VER-OPEN-SOURCE with GNU General Public License v2.0 5 votes vote down vote up
private void updateFloatingMenu() {
    if (mConfig.isLeftHandMode()) {
        CoordinatorLayout.LayoutParams lp = (CoordinatorLayout.LayoutParams) mFam.getLayoutParams();
        lp.gravity = Gravity.START | Gravity.BOTTOM;
        mFam.setExpandDirection(FloatingActionsMenu.EXPAND_UP, FloatingActionsMenu.LABELS_ON_RIGHT_SIDE);
        mFam.setLayoutParams(lp);
    }
}
 
Example #11
Source File: FloatingActionsMenuBehavior.java    From Aria2App with GNU General Public License v3.0 4 votes vote down vote up
private static boolean isScaleMax(@NonNull FloatingActionsMenu view) {
    View animateView = findInnerMenu(view);
    if (animateView == null) animateView = view;
    return animateView.getScaleX() == 1;
}
 
Example #12
Source File: FloatingActionsMenuBehavior.java    From Aria2App with GNU General Public License v3.0 4 votes vote down vote up
@Override
public boolean onStartNestedScroll(@NonNull CoordinatorLayout coordinatorLayout, @NonNull FloatingActionsMenu child, @NonNull View directTargetChild, @NonNull View target, int nestedScrollAxes, @ViewCompat.NestedScrollType int type) {
    return nestedScrollAxes == ViewCompat.SCROLL_AXIS_VERTICAL;
}
 
Example #13
Source File: ScrollAwareFamBehavior.java    From NGA-CLIENT-VER-OPEN-SOURCE with GNU General Public License v2.0 4 votes vote down vote up
public boolean onStartNestedScroll(CoordinatorLayout coordinatorLayout, FloatingActionsMenu child, View directTargetChild, View target, int nestedScrollAxes) {
    return nestedScrollAxes == 2;
}
 
Example #14
Source File: MainActivity.java    From writeily-pro with MIT License 4 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {

    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);

    toolbar = (Toolbar) findViewById(R.id.toolbar);
    if (toolbar != null) {
        setSupportActionBar(toolbar);
    }

    frameLayout = findViewById(R.id.frame);

    fabMenu = (FloatingActionsMenu) findViewById(R.id.fab);
    fabCreateNote = (FloatingActionButton) findViewById(R.id.create_note);
    fabCreateFolder = (FloatingActionButton) findViewById(R.id.create_folder);

    fabCreateNote.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            createNote();
        }
    });

    fabCreateFolder.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            createFolder();
        }
    });

    // Set up the fragments
    notesFragment = new NotesFragment();

    renameBroadcastReceiver = new RenameBroadcastReceiver(notesFragment);
    browseToFolderBroadcastReceiver = new CurrentFolderChangedReceiver(this);

    // Load initial fragment
    FragmentManager fm = getFragmentManager();
    fm.beginTransaction()
            .replace(R.id.frame, notesFragment)
            .commit();

    initFolders();
}