Создаю адаптер и передаю класс с пустым списком:
@Provides
@Singleton
Posts providesItemsList() {
Posts posts = new Posts();
posts.items = new ArrayList<>();
return posts;
}
После чего идет запрос в сеть и вызывается метод адаптера:
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();
}
А вот так выглядит getItemCount:
@Override
public int getItemCount() {
Log.i("mytag", "Posts items number in the getitemcount method: " + Integer.toString(posts.items.size()));
return posts.items.size();
}
И вот что пишет в логах:
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
Как мне правильно обновить мой recyclerview?
Сборка персонального компьютера от Artline: умный выбор для современных пользователей