use of com.example.first_responder_app.recyclerViews.IncidentGroupRecyclerViewAdapter in project FirstResponse by mattpost1700.
the class IncidentGroupFragment method onCreateView.
@Override
public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
binding = DataBindingUtil.inflate(inflater, R.layout.fragment_incident_group, container, false);
listOfIncidentDataModel = new ArrayList<>();
activeUser = AppUtil.getActiveUser(getActivity());
if (activeUser == null) {
getActivity().getFragmentManager().popBackStack();
Toast.makeText(getContext(), "User is not logged in!", Toast.LENGTH_SHORT).show();
}
final SwipeRefreshLayout pullToRefresh = binding.incidentGroupSwipeRefreshLayout;
pullToRefresh.setOnRefreshListener(() -> {
refreshData();
pullToRefresh.setRefreshing(false);
});
IncidentGroupRecyclerViewAdapter.IncidentClickListener incidentClickListener = (view, position) -> {
IncidentDataModel incident = listOfIncidentDataModel.get(position);
IncidentViewModel incidentViewModel = new ViewModelProvider(requireActivity()).get(IncidentViewModel.class);
incidentViewModel.setIncidentDataModel(incident);
NavDirections action = IncidentGroupFragmentDirections.actionIncidentGroupFragmentToIncidentFragment();
Navigation.findNavController(binding.getRoot()).navigate(action);
};
binding.sortIncidentsButton.setOnClickListener(view -> {
PopupMenu popupMenu = new PopupMenu(getContext(), view);
popupMenu.setOnMenuItemClickListener(this);
popupMenu.inflate(R.menu.incident_popup_menu);
popupMenu.show();
});
// Recycler view
RecyclerView incidentRecyclerView = binding.incidentsGroupRecyclerView;
incidentRecyclerView.setLayoutManager(new LinearLayoutManager(getContext()));
incidentGroupRecyclerViewAdapter = new IncidentGroupRecyclerViewAdapter(getContext(), listOfIncidentDataModel);
incidentGroupRecyclerViewAdapter.setIncidentClickListener(incidentClickListener);
incidentRecyclerView.setAdapter(incidentGroupRecyclerViewAdapter);
addIncidentEventListener();
// inflater.inflate(R.layout.fragment_incident_group, container, false);
return binding.getRoot();
}
Aggregations