Is it possible to use DIffUtil/AsyncListDiffer with other Collection than List?

163 Views Asked by At

I'm currently using DiffUtil/AsyncListDiffer with a List collection. I'm using the general adapter/recyclerview/ViewHolder implementation. Items are a List<Uri>.

Can I use a LinkedHashSet instead of a List? Also, if yes, is it a major change?

1

There are 1 best solutions below

0
Mark On BEST ANSWER

Can I use a LinkedHashSet instead of a List? Also, if yes, is it a major change?

No LinkedHashSet implements the Set interface, not the List interface.

Both Set and List have a common parent Collection interface, however List is the hardcoded interface type for DiffUtil and AsyncListDiffer. You would have to create custom implementations for data structures other than the List<T> interface.

Collection/Map cheatsheet :enter image description here