I have around 32 records in json, I am using RecyclerView to show them and I have implemented OnScrollListener(...)
Question
I started an Activity, I fetched all 32 records, now when I do scroll, why I am again getting same 32 records again and again, whenever I do scroll, here is my implementation of OnScrollListener()
public void initializeOnScrollForRecyclerView() {
mRecyclerView.addOnScrollListener(new RecyclerView.OnScrollListener() {
@Override
public void onScrolled(RecyclerView recyclerView, int dx, int dy) {
int visibleItemCount = recyclerView.getLayoutManager().getChildCount();
int totalItemCount = recyclerView.getLayoutManager().getItemCount();
int pastVisiblesItems = ((LinearLayoutManager) recyclerView.getLayoutManager()).findFirstVisibleItemPosition();
if (!isLoading) {
if ((visibleItemCount + pastVisiblesItems) >= totalItemCount) {
isLoading = true;
mPostPresenter.loadPosts(false);
}
}
}
});
}