So, i'm trying to follow the paging library. and in most examples, they have something like:
@Override
public void onBindViewHolder(@NonNull PokemonViewHolder pokemonViewHolder, int i) {
Pokemon pokemon = getItem(i);
if (pokemon != null) { // <-- why this check here?
pokemonViewHolder.bind(pokemon);
}
}
Why do you have to check for the item in the adapter being null? I'm not understanding the internals of the PagedListAdapter flow. Could anyone please explain?
My guess is that we have an observer on the adapter that "nukes" the adapter's content from the UI thread at some point, as soon as the datasource is updated, and thus this item position is outdated?