use of com.example.first_responder_app.recyclerViews.AnnouncementRecyclerViewAdapter in project FirstResponse by mattpost1700.
the class AnnouncementFragment 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_announcement, 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();
}
listOfAnnouncements = new ArrayList<>();
populateAnnouncmentList();
RecyclerView announcementRecyclerView = binding.rvAnnoun;
announcementRecyclerView.setLayoutManager(new LinearLayoutManager(getContext()));
announcementAdapter = new AnnouncementRecyclerViewAdapter(getContext(), listOfAnnouncements);
announcementRecyclerView.setAdapter(announcementAdapter);
final SwipeRefreshLayout pullToRefresh = binding.announcementSwipeRefreshLayout;
pullToRefresh.setOnRefreshListener(() -> {
populateAnnouncmentList();
pullToRefresh.setRefreshing(false);
});
binding.newAnnouncementButton.setOnClickListener(v -> {
NavDirections action = AnnouncementFragmentDirections.actionAnnouncementFragmentToNewAnnouncementFragment();
Navigation.findNavController(binding.getRoot()).navigate(action);
});
return binding.getRoot();
}
Aggregations