use of com.example.first_responder_app.recyclerViews.EventGroupRecyclerViewAdapter in project FirstResponse by mattpost1700.
the class EventGroupFragment method onCreateView.
@Override
public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
// binding fragment with nav_map by using navHostFragment, throw this block of code in there and that allows you to switch to other fragments
binding = DataBindingUtil.inflate(inflater, R.layout.fragment_event_group, container, false);
NavHostFragment navHostFragment = (NavHostFragment) getActivity().getSupportFragmentManager().findFragmentById(R.id.nav_host_fragment);
NavController navController = navHostFragment.getNavController();
activeUser = AppUtil.getActiveUser(getActivity());
if (activeUser == null) {
getActivity().getFragmentManager().popBackStack();
Toast.makeText(getContext(), "User is not logged in!", Toast.LENGTH_SHORT).show();
}
listOfEvents = new ArrayList<>();
populateEventList();
EventGroupRecyclerViewAdapter.ItemClickListener eventClickListener = ((view, position, data) -> {
// passing data to event
mViewModel = new ViewModelProvider(requireActivity()).get(EventViewModel.class);
mViewModel.setEventDetail(data);
NavDirections action = EventGroupFragmentDirections.actionEventGroupFragmentToEventFragment();
Navigation.findNavController(binding.getRoot()).navigate(action);
});
RecyclerView eventGroupRecyclerView = binding.eventgroupRecycler;
eventGroupRecyclerView.setLayoutManager(new LinearLayoutManager(getContext()));
eventGroupRecyclerViewAdapter = new EventGroupRecyclerViewAdapter(getContext(), listOfEvents);
eventGroupRecyclerViewAdapter.setClickListener(eventClickListener);
eventGroupRecyclerView.setAdapter(eventGroupRecyclerViewAdapter);
final SwipeRefreshLayout pullToRefresh = binding.eventSwipeRefreshLayout;
pullToRefresh.setOnRefreshListener(() -> {
populateEventList();
pullToRefresh.setRefreshing(false);
});
binding.newEventButton.setOnClickListener(v -> {
NavDirections action = EventGroupFragmentDirections.actionEventGroupFragmentToNewEventFragment();
Navigation.findNavController(binding.getRoot()).navigate(action);
});
return binding.getRoot();
}
Aggregations