Здравствуйте, ребята в чем тут проблема.
//MainActivity.java
private int previousTotal = 0;
private boolean loading = true;
private int visibleThreshold = 5;
int firstVisibleItem, visibleItemCount, totalItemCount;
private int currentPage = 0;
@Override
public onCreate(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState)
{
listView = (RecyclerView) findViewById(R.id.recycler);
listView.addOnScrollListener(new RecyclerView.OnScrollListener()
{
@Override
public void onScrolled(RecyclerView recyclerView, int dx, int dy)
{
super.onScrolled(recyclerView, dx, dy);
visibleItemCount = recyclerView.getChildCount();
totalItemCount = layoutManager.getItemCount();
firstVisibleItem = layoutManager.findFirstVisibleItemPosition();
if (loading)
{
if (totalItemCount > previousTotal) {
loading = false;
previousTotal = totalItemCount;
currentPage++;
}
}
if (!loading && (totalItemCount - visibleItemCount)
<= (firstVisibleItem + visibleThreshold)) {
// End has been reached
load();
loading = true;
}
}
});
this.load();
}
protected void loadI()
{
Call<list> call = api().list(10 * currentPage);
call.enqueue(new Callback<UserItems>()
{
@Override
public void onResponse(Call<list> call, Response<list> response)
{
if(response.isSuccessful())
{
for (Items item : response.body().items())
{
Log.d("items", String.valueOf(item.id()));
}
}
adapter.notifyDataSetChanged();
}
@Override
public void onFailure(@NonNull Call<UserItems> call, @NonNull Throwable t) {
Log.d("error_messages", "Данные не получены");
}
});
}
Этот код должен выводиться постранично, но он сразу вытаскивает несколько страниц, в чем тут может быть проблема.