use of com.example.flashgig.fragments.HomeFragment in project FIREBASE_TEST_JAVA by essantos8.
the class MainActivity method onCreate.
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
replaceFragment(new HomeFragment(), "home", "LtoR");
ActivityMainBinding binding = ActivityMainBinding.inflate(getLayoutInflater());
setContentView(binding.getRoot());
binding.bottomNavigationView.setOnItemSelectedListener(item -> {
Fragment curFragment = getSupportFragmentManager().findFragmentById(R.id.frameLayout);
assert curFragment != null;
String curFragmentTag = curFragment.getTag();
assert curFragmentTag != null : "Set a fragment tag!";
switch(item.getItemId()) {
case R.id.home:
if (!curFragmentTag.equals("home")) {
replaceFragment(new HomeFragment(), "home", "LtoR");
}
break;
case R.id.messages:
if (!curFragmentTag.equals("messages")) {
if (!curFragmentTag.equals("home")) {
replaceFragment(new MessagesFragment(), "messages", "LtoR");
} else {
replaceFragment(new MessagesFragment(), "messages", "RtoL");
}
}
break;
case R.id.myJobs:
if (!curFragmentTag.equals("myJobs")) {
if (!curFragmentTag.equals("profile")) {
replaceFragment(new MyJobsFragment(), "myJobs", "RtoL");
} else {
replaceFragment(new MyJobsFragment(), "myJobs", "LtoR");
}
}
break;
case R.id.profile:
if (!curFragmentTag.equals("profile")) {
replaceFragment(new ProfileFragment(), "profile", "RtoL");
}
break;
}
return true;
});
}
Aggregations