Search in sources :

Example 1 with FloatingActionButton

use of carbon.widget.FloatingActionButton in project Carbon by ZieIony.

the class FloatingActionMenuActivity method onCreate.

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_floatingactionmenu);
    FloatingActionButton fab = (FloatingActionButton) findViewById(R.id.fab);
    fab.setMenu(R.menu.menu_fab);
}
Also used : FloatingActionButton(carbon.widget.FloatingActionButton)

Example 2 with FloatingActionButton

use of carbon.widget.FloatingActionButton in project Carbon by ZieIony.

the class QuickReturnActivity method onCreate.

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_quickreturn);
    RecyclerView recyclerView = (RecyclerView) findViewById(R.id.recycler);
    recyclerView.setLayoutManager(new LinearLayoutManager(this, LinearLayoutManager.VERTICAL, false));
    recyclerView.setAdapter(new FruitAdapter(fruits, null));
    final FloatingActionButton fab = (FloatingActionButton) findViewById(R.id.fab);
    final Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
    recyclerView.addOnScrollListener(new android.support.v7.widget.RecyclerView.OnScrollListener() {

        int yscroll = 0;

        @Override
        public void onScrolled(android.support.v7.widget.RecyclerView recyclerView, int dx, int dy) {
            super.onScrolled(recyclerView, dx, dy);
            if (fab.getVisibility() == View.VISIBLE && fab.getAnimator() == null && yscroll > 50 * Carbon.getDip(getApplicationContext())) {
                yscroll = 0;
                fab.setVisibility(View.GONE);
                toolbar.setVisibility(View.GONE);
            }
            if (fab.getVisibility() != View.VISIBLE && fab.getAnimator() == null && yscroll < -50 * Carbon.getDip(getApplicationContext())) {
                yscroll = 0;
                fab.setVisibility(View.VISIBLE);
                toolbar.setVisibility(View.VISIBLE);
            }
            if (Math.signum(dy) != Math.signum(yscroll))
                yscroll = 0;
            yscroll += dy;
        }
    });
}
Also used : FruitAdapter(tk.zielony.carbonsamples.applibrary.FruitAdapter) LinearLayoutManager(android.support.v7.widget.LinearLayoutManager) FloatingActionButton(carbon.widget.FloatingActionButton) RecyclerView(carbon.widget.RecyclerView) Toolbar(carbon.widget.Toolbar)

Example 3 with FloatingActionButton

use of carbon.widget.FloatingActionButton in project Carbon by ZieIony.

the class SnackbarActivity method onCreate.

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_snackbar);
    final CheckBox tapCheckBox = (CheckBox) findViewById(R.id.tap);
    final CheckBox swipeCheckBox = (CheckBox) findViewById(R.id.swipe);
    final CheckBox floatingCheckBox = (CheckBox) findViewById(R.id.floating);
    final CheckBox infiniteCheckBox = (CheckBox) findViewById(R.id.infinite);
    final CheckBox pushCheckBox = (CheckBox) findViewById(R.id.push);
    final FloatingActionButton fab = (FloatingActionButton) findViewById(R.id.fab);
    findViewById(R.id.button).setOnClickListener(view -> {
        final Snackbar snackbar = new Snackbar(SnackbarActivity.this, "Hello world!", "dismiss", infiniteCheckBox.isChecked() ? Snackbar.INFINITE : getResources().getInteger(R.integer.carbon_snackbarDuration));
        snackbar.setOnClickListener(v -> snackbar.dismiss());
        snackbar.setStyle(floatingCheckBox.isChecked() ? Snackbar.Style.Floating : Snackbar.Style.Docked);
        snackbar.setTapOutsideToDismissEnabled(tapCheckBox.isChecked());
        snackbar.setSwipeToDismissEnabled(swipeCheckBox.isChecked());
        if (pushCheckBox.isChecked())
            snackbar.addPushedView(fab);
        snackbar.show((ViewGroup) getWindow().getDecorView().getRootView());
        snackbar.setOnDismissListener(() -> {
        });
    });
    Snackbar.clearQueue();
}
Also used : CheckBox(carbon.widget.CheckBox) FloatingActionButton(carbon.widget.FloatingActionButton) Snackbar(carbon.widget.Snackbar)

Aggregations

FloatingActionButton (carbon.widget.FloatingActionButton)3 LinearLayoutManager (android.support.v7.widget.LinearLayoutManager)1 CheckBox (carbon.widget.CheckBox)1 RecyclerView (carbon.widget.RecyclerView)1 Snackbar (carbon.widget.Snackbar)1 Toolbar (carbon.widget.Toolbar)1 FruitAdapter (tk.zielony.carbonsamples.applibrary.FruitAdapter)1