use of com.example.first_responder_app.databinding.FragmentIncidentBinding in project FirstResponse by mattpost1700.
the class IncidentFragment method onCreateView.
@Override
public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
FragmentIncidentBinding binding = DataBindingUtil.inflate(inflater, R.layout.fragment_incident, container, false);
NavHostFragment navHostFragment = (NavHostFragment) getActivity().getSupportFragmentManager().findFragmentById(R.id.nav_host_fragment);
bindingView = binding.getRoot();
context = getContext();
Log.d(TAG, "onCreateView: " + bindingView.findViewById(R.id.incident_button_layout));
Bundle mapViewBundle = null;
if (savedInstanceState != null) {
mapViewBundle = savedInstanceState.getBundle(MAPVIEW_BUNDLE_KEY);
}
mMapView = (MapView) binding.googleMapView;
mMapView.onCreate(mapViewBundle);
mMapView.getMapAsync(this);
mViewModel = new ViewModelProvider(requireActivity()).get(IncidentViewModel.class);
incident = mViewModel.getIncidentDataModel();
responderList = new ArrayList<>();
Log.d(TAG, "onCreate: " + getActivity().findViewById(R.id.incident_button_layout));
initializeIncident(incident);
// TODO: Check if user has permissions to file report (If not hide FAB)
binding.incidentFileReportButton.setOnClickListener(v -> {
ReportViewModel userViewModel = new ViewModelProvider(requireActivity()).get(ReportViewModel.class);
userViewModel.setIncidentDataModel(incidentDataModel);
NavDirections action = IncidentFragmentDirections.actionIncidentFragmentToReportFragment();
Navigation.findNavController(binding.getRoot()).navigate(action);
});
// setup the dialog upon clicking the responder count icon, clicking on individual item will redirect to their profile page
binding.incidentRespondingCount.setOnClickListener(v -> {
AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());
LayoutInflater layoutInflater = getLayoutInflater();
View view = layoutInflater.inflate(R.layout.dialog_title, null);
builder.setCustomTitle(view).setItems(responderArr, (dialogInterface, i) -> {
mUserViewModel = new ViewModelProvider(requireActivity()).get(UserViewModel.class);
mUserViewModel.setUserDataModel(responderList.get(i));
NavDirections action = IncidentFragmentDirections.actionIncidentFragmentToUserFragment();
Navigation.findNavController(binding.getRoot()).navigate(action);
});
builder.setNegativeButton("Cancel", (dialogInterface, i) -> {
});
AlertDialog dialog = builder.create();
dialog.show();
});
return binding.getRoot();
}
Aggregations