use of com.roughike.bottombar.BottomBarTab in project Roblu by wdavies973.
the class FormViewer method onCreate.
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_create_form);
/*
* Load dependencies
*/
/*
Stores the user's UI preferences
*/
RUI rui = new IO(getApplicationContext()).loadSettings().getRui();
/*
* Setup UI
*/
// Toolbar
Toolbar toolbar = findViewById(R.id.toolbar);
setSupportActionBar(toolbar);
if (getSupportActionBar() != null) {
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
getSupportActionBar().setTitle("Form editor");
if (getIntent().getBooleanExtra("master", false))
getSupportActionBar().setSubtitle("Master form");
}
// Bottom bar - selector that lets the user switch between PIT and MATCH forms
BottomBar bBar = findViewById(R.id.bottomBar);
bBar.setOnTabSelectListener(this);
BottomBarTab tab = bBar.getTabAtPosition(0);
BottomBarTab tab2 = bBar.getTabAtPosition(1);
tab.setBarColorWhenSelected(rui.getPrimaryColor());
tab2.setBarColorWhenSelected(rui.getPrimaryColor());
bBar.selectTabAtPosition(0);
// Add the "New metric" button
FloatingActionButton fab = findViewById(R.id.fab);
fab.setOnClickListener(this);
// Recycler view setup
RecyclerView rv = findViewById(R.id.movie_recycler_view);
LinearLayoutManager linearLayoutManager = new LinearLayoutManager(this);
linearLayoutManager.setOrientation(LinearLayoutManager.VERTICAL);
rv.setLayoutManager(linearLayoutManager);
((SimpleItemAnimator) rv.getItemAnimator()).setSupportsChangeAnimations(false);
metricsAdapter = new FormRecyclerAdapter(this, this);
rv.setAdapter(metricsAdapter);
// Gesture helper
ItemTouchHelper.Callback callback = new FormRecyclerTouchHelper(metricsAdapter);
ItemTouchHelper helper = new ItemTouchHelper(callback);
helper.attachToRecyclerView(rv);
/*
* Check to see if we received a form from a different class or
* if we need to create a new one
*/
if (getIntent().getSerializableExtra("form") != null) {
form = (RForm) getIntent().getSerializableExtra("form");
} else {
RTextfield name = new RTextfield(0, "Team name", false, true, "");
RTextfield number = new RTextfield(1, "Team number", true, true, "");
ArrayList<RMetric> pit = new ArrayList<>();
pit.add(name);
pit.add(number);
form = new RForm(pit, new ArrayList<RMetric>());
}
loadViews(true, 0);
new UIHandler(this, toolbar, fab).update();
}
use of com.roughike.bottombar.BottomBarTab in project BottomBar by roughike.
the class BadgeActivity method onCreate.
@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_three_tabs);
messageView = (TextView) findViewById(R.id.messageView);
final BottomBar bottomBar = (BottomBar) findViewById(R.id.bottomBar);
bottomBar.setOnTabSelectListener(new OnTabSelectListener() {
@Override
public void onTabSelected(@IdRes int tabId) {
messageView.setText(TabMessage.get(tabId, false));
}
});
bottomBar.setOnTabReselectListener(new OnTabReselectListener() {
@Override
public void onTabReSelected(@IdRes int tabId) {
Toast.makeText(getApplicationContext(), TabMessage.get(tabId, true), Toast.LENGTH_LONG).show();
}
});
BottomBarTab nearby = bottomBar.getTabWithId(R.id.tab_nearby);
nearby.setBadgeCount(5);
}
Aggregations