I'm using a RecyclerView
where there is a boolean involved in getItemCount()
. This boolean value controls the visibility of the last item in the RecyclerView
, kinda like a load more view, but slightly different. From time to time, the value of this boolean changes, so the RecyclerView
will know whether to include the last item.
The code looks something like this
@Override
public int getItemCount() {
return mItemArray.size() + (shouldShow ? 1 : 0);
}
When the value of shouldShow
gets updated, I'm not calling notifyDataSetChanged()
or notifyItemChanged()
, but the RecyclerView
still gets updated properly. But I worry it will eventually cause the RecyclerView
to crash because of inconsistency. My questions are,
getItemCount()
a proper way to control RecyclerView
size?notify...()
when the value of this boolean changes?RecyclerView
crashes for inconsistency because of this?1.not a problem untill you are passing int in it 2.there is no need to call notifydatasetchanged(we should call them when their is change in adapter data) 3.there will not be any consistency