use of com.google.firebase.quickstart.database.databinding.ActivityMainBinding in project quickstart-android by firebase.
the class MainActivity method onCreate.
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
ActivityMainBinding binding = ActivityMainBinding.inflate(getLayoutInflater());
setContentView(binding.getRoot());
setSupportActionBar(binding.toolbar);
fab = binding.fab;
navController = Navigation.findNavController(this, R.id.nav_host_fragment);
navController.setGraph(R.navigation.nav_graph_java);
navController.addOnDestinationChangedListener(new NavController.OnDestinationChangedListener() {
@Override
public void onDestinationChanged(@NonNull NavController controller, @NonNull NavDestination destination, @Nullable Bundle arguments) {
if (destination.getId() == R.id.MainFragment) {
fab.setVisibility(View.VISIBLE);
fab.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
navController.navigate(R.id.action_MainFragment_to_NewPostFragment);
}
});
} else {
fab.setVisibility(View.GONE);
}
}
});
}
Aggregations