use of com.roughike.bottombar.OnMenuTabClickListener in project ApertureGallery by MJonesDev.
the class ActivityHome method onCreate.
@Override
protected // TODO - Check if permissions have been granted. If not, request
void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(com.marlonjones.projectevo.R.layout.activity_home);
final Toolbar toolbar = (Toolbar) findViewById(R.id.tool_bar);
// This may be changed once the app's name is changed
toolbar.setTitle("Albums");
setSupportActionBar(toolbar);
// Message at start of app!
new MaterialDialog.Builder(this).title(R.string.alpha_title).content(R.string.alpha_text).positiveText(R.string.OK).show();
// Asks for permission. Works, sort of. Temporary Solution
new AskPermission.Builder(this).setPermissions(Manifest.permission.CAMERA, Manifest.permission.READ_EXTERNAL_STORAGE).setCallback(this).setErrorCallback(this).request(GET_PERMISSIONS);
// TODO: Consider changing UI to be better, and consider adding Drive/Dropbox support.
// Fragments are named after explosives seen in COD: MW3
mContext = ActivityHome.this;
BottomBar BotLane = BottomBar.attach(this, savedInstanceState);
// This is due to not being deved for tablets. No need to.
BotLane.noTabletGoodness();
BotLane.setItems(R.menu.bottombar_menu);
BotLane.setOnMenuTabClickListener(new OnMenuTabClickListener() {
// Consider replacing with Google Bottom Bar from Android Design Library
@Override
public void onMenuTabSelected(@IdRes int menuItemId) {
if (menuItemId == R.id.bottomBarItemOne) {
toolbar.setTitle("Albums");
Fragment semtexFrag = new GalleryFragment();
FragmentTransaction ft = getSupportFragmentManager().beginTransaction();
ft.replace(R.id.fragment_container, semtexFrag);
ft.setTransition(FragmentTransaction.TRANSIT_FRAGMENT_FADE);
ft.addToBackStack(null);
ft.commit();
}
if (menuItemId == R.id.bottomBarItemTwo) {
toolbar.setTitle("Camera");
Fragment claymoreFrag = new CameraFragment();
FragmentTransaction ft = getSupportFragmentManager().beginTransaction();
ft.replace(R.id.fragment_container, claymoreFrag);
ft.setTransition(FragmentTransaction.TRANSIT_FRAGMENT_FADE);
ft.addToBackStack(null);
ft.commit();
}
if (menuItemId == R.id.bottomBarItemThree) {
toolbar.setTitle("Videos");
Fragment moabFrag = new VideoFragment();
FragmentTransaction ft = getSupportFragmentManager().beginTransaction();
ft.replace(R.id.fragment_container, moabFrag);
ft.setTransition(FragmentTransaction.TRANSIT_FRAGMENT_FADE);
ft.addToBackStack(null);
ft.commit();
}
}
@Override
public void onMenuTabReSelected(@IdRes int menuItemId) {
if (menuItemId == R.id.bottomBarItemOne) {
// The user reselected item number one, scroll your content to top.
// TODO - Add in "Scroll to top" function for better UX.
}
}
});
}
Aggregations