If we use DiffUtil.Callback
, and do
adapter.setItems(itemList);
diff.dispatchUpdatesTo(adapter);
how can we make sure that adding of new elements will scroll to that new position.
I have a case where I see item disappear, and a new one is created as a first element at the top, but not visible. It is hidden on top until you scroll down to make it visible.
Before using DiffUtil
, I was implementing this manually, and after I knew I was inserting at some position (on top) I could scroll to.
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…