I am getting this WARNING everytime when I want to load data
[Cannot call this method in a scroll callback. Scroll callbacks might be run during a measure & layout pass where you cannot change the RecyclerView data. Any method call that might change the structure of the RecyclerView or the adapter contents should be postponed to the next frame.]
recyclerView.addOnScrollListener(new RecyclerView.OnScrollListener()
{
@OverRide
public void onScrolled(RecyclerView recyclerView, int dx, int dy)
{
super.onScrolled(recyclerView, dx, dy);
totalItemCount = linearLayoutManager.getItemCount();
lastVisibleItem = linearLayoutManager.findLastVisibleItemPosition();
if (!isLoading && totalItemCount <= (lastVisibleItem + visibleThreshold))
{
if (onLoadMoreListener != null)
{
onLoadMoreListener.onLoadMore(); // Here is the warning //
}
isLoading = true;
}
}
});