use of oscar.riksdagskollen.Utilities.CurrentNewsListAdapter in project Riksdagskollen by OAndell.
the class CurrentNewsListFragment method onCreateView.
@Nullable
@Override
public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
View view = inflater.inflate(R.layout.fragment_party_list, null);
currentNewsListAdapter = new CurrentNewsListAdapter(newsList);
recyclerView = view.findViewById(R.id.recycler_view);
recyclerView.setAdapter(currentNewsListAdapter);
recyclerView.setNestedScrollingEnabled(true);
final LinearLayoutManager mLayoutManager = new LinearLayoutManager(getContext());
recyclerView.setLayoutManager(mLayoutManager);
recyclerView.addOnScrollListener(new RecyclerView.OnScrollListener() {
@Override
public void onScrolled(RecyclerView recyclerView, int dx, int dy) {
if (// check for scroll down
dy > 0) {
int visibleItemCount = mLayoutManager.getChildCount();
int totalItemCount = mLayoutManager.getItemCount();
pastVisiblesItems = mLayoutManager.findFirstVisibleItemPosition();
if ((visibleItemCount + pastVisiblesItems) >= totalItemCount) {
if (!loading)
loadNextPage();
}
}
}
});
loadingView = view.findViewById(R.id.loading_view);
loadNextPage();
return view;
}
Aggregations