I’m using the following OnScrollListener to pull more pages from Flickr, but I’m finding that sometimes it’s executing the FetchItemsTask several times on one scroll to bottom. I’m thinking this has to do with the delay in receiving the new page/updating UI, but not sure if anyone has any suggestions to prevent this?
mPhotoRecyclerView.addOnScrollListener(new RecyclerView.OnScrollListener() {
GridLayoutManager manager = (GridLayoutManager)mPhotoRecyclerView
.getLayoutManager();
@Override
public void onScrolled(RecyclerView recyclerView, int dx, int dy) {
mLastPosition = manager.findLastVisibleItemPosition();
if(mLastPosition == mItems.size() - 1){
Toast.makeText(getActivity(), "Bottom", Toast.LENGTH_SHORT).show();
new FetchItemsTask().execute();
}
}
});