androidandroid-recyclerviewandroid-adapterandroid-viewholderandroid-diffutils

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


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?


Solution

  • 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