@Override
public void onBindItemViewHolder(ItemViewHolder viewHolder, int sectionIndex, int itemIndex, int itemType) {
int sectionPosition = includeHeader ? sectionIndex - 1 : sectionIndex;
switch (itemType) {
case ITEM_HEADER:
...
break;
case ITEM_TILE:
initTile((FeedViewHolder) viewHolder, feedDataProviders.get(sectionPosition).getTileViewModelList().get(itemIndex), sectionPosition);
break;
case ITEM_FOOTER:
...
break;
default:
break;
}
}
Where feedDataProviders is List<FeedDataProvider>. FeedDataProvider has list of custom objects TileViewModel.
I got IndexOutOfBoundsException: Invalid index 0, size is 0 in line initTile() because getTileViewModelList() return empty list and itemIndex is 0. I think if getNumberOfItemsInSection return 0 then is should not called the onBindItemViewHolder right?
I found one issue
Where
feedDataProviders
isList<FeedDataProvider>
.FeedDataProvider
has list of custom objectsTileViewModel
.I got
IndexOutOfBoundsException: Invalid index 0, size is 0
in lineinitTile()
becausegetTileViewModelList()
return empty list anditemIndex
is 0. I think ifgetNumberOfItemsInSection
return 0 then is should not called theonBindItemViewHolder
right?