Search in sources :

Example 1 with FABsMenu

use of jahirfiquitiva.libs.fabsmenu.FABsMenu in project AmazeFileManager by TeamAmaze.

the class MainActivity method initialiseFab.

void initialiseFab() {
    int colorAccent = getColorPreference().getColor(ColorUsage.ACCENT);
    floatingActionButton = findViewById(R.id.fabs_menu);
    floatingActionButton.getMenuButton().setBackgroundColor(colorAccent);
    floatingActionButton.getMenuButton().setRippleColor(Utils.getColor(this, R.color.white_translucent));
    floatingActionButton.setAnimationDuration(500);
    floatingActionButton.setMenuListener(new FABsMenuListener() {

        @Override
        public void onMenuExpanded(FABsMenu fabsMenu) {
            showSmokeScreen();
        }

        @Override
        public void onMenuCollapsed(FABsMenu fabsMenu) {
            hideSmokeScreen();
        }
    });
    floatingActionButton.setMenuListener(new FABsMenuListener() {

        @Override
        public void onMenuExpanded(FABsMenu fabsMenu) {
            FileUtils.revealShow(fabBgView, true);
        }

        @Override
        public void onMenuCollapsed(FABsMenu fabsMenu) {
            FileUtils.revealShow(fabBgView, false);
        }
    });
    initFabTitle(findViewById(R.id.menu_new_folder), MainActivityHelper.NEW_FOLDER);
    initFabTitle(findViewById(R.id.menu_new_file), MainActivityHelper.NEW_FILE);
    initFabTitle(findViewById(R.id.menu_new_cloud), MainActivityHelper.NEW_CLOUD);
}
Also used : FABsMenuListener(jahirfiquitiva.libs.fabsmenu.FABsMenuListener) FABsMenu(jahirfiquitiva.libs.fabsmenu.FABsMenu)

Example 2 with FABsMenu

use of jahirfiquitiva.libs.fabsmenu.FABsMenu in project FABsMenu by jahirfiquitiva.

the class MainActivity method onCreate.

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    AppCompatDelegate.setCompatVectorFromResourcesEnabled(true);
    setContentView(R.layout.activity_main);
    Button snackButton = findViewById(R.id.snack_button);
    snackButton.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View view) {
            Snackbar.make(findViewById(R.id.coordinator), "Testing, testing, 1, 2, 3", Snackbar.LENGTH_LONG).show();
        }
    });
    RecyclerView rv = findViewById(R.id.rv);
    rv.setLayoutManager(new LinearLayoutManager(this, LinearLayoutManager.VERTICAL, false));
    rv.addItemDecoration(new DividerItemDecoration(this, DividerItemDecoration.VERTICAL));
    rv.setAdapter(new SampleAdapter(this));
    menu = findViewById(R.id.fabs_menu);
    menu.attachToRecyclerView(rv);
    menu.setMenuListener(new FABsMenuListener() {

        // You don't need to override all methods. Just the ones you want.
        @Override
        public void onMenuClicked(FABsMenu fabsMenu) {
            // Default implementation opens the menu on click
            super.onMenuClicked(fabsMenu);
        // showToast("You pressed the menu!");
        }

        @Override
        public void onMenuCollapsed(FABsMenu fabsMenu) {
            super.onMenuCollapsed(fabsMenu);
        // showToast("The menu has been collapsed!");
        }

        @Override
        public void onMenuExpanded(FABsMenu fabsMenu) {
            super.onMenuExpanded(fabsMenu);
        // showToast("The menu has been expanded!");
        }
    });
    TitleFAB clickableTitle = findViewById(R.id.clickable_title);
    clickableTitle.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View view) {
            showToast("You pressed the red fab or its title");
        }
    });
    TitleFAB mini = findViewById(R.id.mini_fab);
    mini.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View view) {
            showToast("You pressed the mini fab!");
        }
    });
    TitleFAB green = findViewById(R.id.green_fab);
    green.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View view) {
            showToast("You pressed the green fab");
        }
    });
    // Removes a button
    TitleFAB toRemove = findViewById(R.id.to_remove);
    menu.removeButton(toRemove);
    // Adds a button to the bottom
    final TitleFAB toAdd = new TitleFAB(this);
    toAdd.setTitle("A new added fab");
    toAdd.setBackgroundColor(Color.parseColor("#ff5722"));
    toAdd.setTitleClickEnabled(true);
    toAdd.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View view) {
            showToast("You pressed the new button");
            toAdd.hide();
        }
    });
    menu.addButton(toAdd);
}
Also used : Button(android.widget.Button) FABsMenuListener(jahirfiquitiva.libs.fabsmenu.FABsMenuListener) RecyclerView(android.support.v7.widget.RecyclerView) FABsMenu(jahirfiquitiva.libs.fabsmenu.FABsMenu) TitleFAB(jahirfiquitiva.libs.fabsmenu.TitleFAB) LinearLayoutManager(android.support.v7.widget.LinearLayoutManager) DividerItemDecoration(android.support.v7.widget.DividerItemDecoration) RecyclerView(android.support.v7.widget.RecyclerView) View(android.view.View)

Aggregations

FABsMenu (jahirfiquitiva.libs.fabsmenu.FABsMenu)2 FABsMenuListener (jahirfiquitiva.libs.fabsmenu.FABsMenuListener)2 DividerItemDecoration (android.support.v7.widget.DividerItemDecoration)1 LinearLayoutManager (android.support.v7.widget.LinearLayoutManager)1 RecyclerView (android.support.v7.widget.RecyclerView)1 View (android.view.View)1 Button (android.widget.Button)1 TitleFAB (jahirfiquitiva.libs.fabsmenu.TitleFAB)1