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);
}
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;
}
});
}
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();
}
Aggregations