use of com.example.first_responder_app.recyclerViews.RespondersGroupRecyclerViewAdapter in project FirstResponse by mattpost1700.
the class RespondingFragment method onCreateView.
@Override
public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
binding = DataBindingUtil.inflate(inflater, R.layout.fragment_responding, container, false);
listOfRespondingDataModel = new ArrayList<>();
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.respondingSwipeRefreshLayout;
pullToRefresh.setOnRefreshListener(() -> {
refreshData();
pullToRefresh.setRefreshing(false);
});
// onclick
RespondersGroupRecyclerViewAdapter.ResponderClickListener responderClickListener = (view, position) -> {
UserViewModel userViewModel = new ViewModelProvider(requireActivity()).get(UserViewModel.class);
userViewModel.setUserDataModel(listOfRespondingDataModel.get(position));
NavDirections action = RespondingFragmentDirections.actionRespondingFragmentToUserFragment();
Navigation.findNavController(binding.getRoot()).navigate(action);
};
binding.sortRespondersButton.setOnClickListener(view -> {
PopupMenu popupMenu = new PopupMenu(getContext(), view);
popupMenu.setOnMenuItemClickListener(this);
popupMenu.inflate(R.menu.user_popup_menu);
popupMenu.show();
});
// Recycler view
RecyclerView respondingRecyclerView = binding.respondingRecyclerView;
respondingRecyclerView.setLayoutManager(new LinearLayoutManager(getContext()));
respondingRecyclerViewAdapter = new RespondersGroupRecyclerViewAdapter(getContext(), listOfRespondingDataModel, listOfIncidentDataModel);
respondingRecyclerViewAdapter.setResponderClickListener(responderClickListener);
respondingRecyclerView.setAdapter(respondingRecyclerViewAdapter);
addResponderEventListener();
addIncidentEventListener();
return binding.getRoot();
}
Aggregations