I am comparing the two list to find the differences between them using a custom implementation DiffUtil Callback but those two list have different size and when i logged the elements being compared in both the list in 'areItemsTheSame' and 'areContentsTheSame' elements that are compared are limited by the size of the list with least elements and hence when in my adapter i call 'dispatchUpdatesTo' the new item is added but its content are same as the last items from old list
Implementation of those methods :
@Override
public boolean areItemsTheSame(int oldItemPosition, int newItemPosition) {
return mOldList.get(oldItemPosition).equals(mNewList.get(newItemPosition));
}
@Override
public boolean areContentsTheSame(int oldItemPosition, int newItemPosition) {
return mOldList.get(oldItemPosition).equals(mNewList.get(newItemPosition));
}
Eg :
(Old)List A = "A","B","C","D","E","F","G","I"
(New)List B = "A","B","C","D","E","F","G","I","K"
upon logging i found that 'areItemsTheSame' and 'areContentsTheSame' only compares element up-to "I" and hence returns true for all calls and after calling dispatchUpdatesTo for adapter new item is added to list but it is "I" not "k"
So what i get is List A = "A","B","C","D","E","F","G","I","I"