I create an adapter and pass the class with an empty list:
@Provides @Singleton Posts providesItemsList() { Posts posts = new Posts(); posts.items = new ArrayList<>(); return posts; } After that there is a request to the network and the adapter method is called:
public void setItems(Posts newPosts) { Log.i("mytag", "NewPosts items number in the setItems method: " + Integer.toString(newPosts.items.size())); posts.items.addAll(newPosts.items); Log.i("mytag", "Posts items number in the setItems method: " + Integer.toString(posts.items.size())); posts.profiles.addAll(newPosts.profiles); posts.groups.addAll(newPosts.groups); notifyDataSetChanged(); } This is what getItemCount looks like:
@Override public int getItemCount() { Log.i("mytag", "Posts items number in the getitemcount method: " + Integer.toString(posts.items.size())); return posts.items.size(); } And that's what he writes in the logs:
07-15 18:57:41.967 7481-7481/com.ovchinnikovm.android.vktop I/mytag: Posts items number in the getitemcount method: 0 07-15 18:57:41.967 7481-7481/com.ovchinnikovm.android.vktop I/mytag: Posts items number in the getitemcount method: 0 07-15 18:57:42.005 7481-7481/com.ovchinnikovm.android.vktop I/mytag: Posts items number in the getitemcount method: 0 07-15 18:57:42.005 7481-7481/com.ovchinnikovm.android.vktop I/mytag: Posts items number in the getitemcount method: 0 07-15 18:57:42.118 7481-7481/com.ovchinnikovm.android.vktop I/mytag: NewPosts items number in the setItems method: 20 07-15 18:57:42.118 7481-7481/com.ovchinnikovm.android.vktop I/mytag: Posts items number in the setItems method: 20 How do I properly update my recyclerview?