Search in sources :

Example 1 with Snackbar

use of carbon.widget.Snackbar 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

CheckBox (carbon.widget.CheckBox)1 FloatingActionButton (carbon.widget.FloatingActionButton)1 Snackbar (carbon.widget.Snackbar)1