public void diffUpdate ( List < T > newList ) { if ( getCollection ( ) . size ( ) == 0 ) { addAll ( newList ) ; notifyDataSetChanged ( ) ; } else { DiffCallback diffCallback = new DiffCallback ( collection , newList ) ; DiffUtil . DiffResult diffResult = DiffUtil . calculateDiff ( diffCallback ) ; clear ( ) ; addAll ( newList ) ; diffResult . dispatchUpdatesTo ( this ) ; } }
Provides a ready to use diff update for our adapter based on the implementation of the standard equals method from Object .