Open asifrpatel opened 5 years ago
I have the same problem. Can this be looked at?
This happened to me when I firstly passed empty list to adapter, and then passed not empty list.
Now my code looks:
if (items.isNotEmpty) { adapter.setItems(items) adapter.notifyDataSetChanged() }
is there any workaround?
my case I tried
override fun submitList(list: List<Swipe>?) {
if (!firstCommit) {
super.submitList(list) {
notifyDataSetChanged()
}
firstCommit = true
} else {
super.submitList(list)
}
}
note that
val holder = vStackView.findViewHolderForAdapterPosition(position)
holder is null in this particular case
This happens because s.didStructureChange() returns false or getTopView() returns null. It returns false or null on some cases, for example: your adapter has empty data list and you try push new data with DiffUtil. In this case notifyDataSetChanged
will not be called.
For prevent this behavior add some check (for ex: YourAdapter#data.isEmpty()) before using DiffUtil and if your current adapter data is empty — use common way with notifyDataSetChanged
instead of DiffUtil.
my case I tried
override fun submitList(list: List<Swipe>?) { if (!firstCommit) { super.submitList(list) { notifyDataSetChanged() } firstCommit = true } else { super.submitList(list) } }
note that
val holder = vStackView.findViewHolderForAdapterPosition(position)
holder is null in this particular case
This helped me..Thanks..
When items are loaded, then onCardAppeared() is not called for position 0.