RVRendererAdapter.addAll doesn't respect Collection.addAll signature
Serchinastico opened this issue · 4 comments
RVRendererAdapter addAll signature differs from the Collection one making it impossible to use it with collections of subtypes.
The fix is as easy as changing the method signature from
public void addAll(Collection<T> elements)
to
public void addAll(Collection<? extends T> elements)
It will be backwards compatible which is always nice.
@Serchinastico the library adapters should implement List<T>
. If you send a PR can be awesome! :)
I don't see why they should, there are some List
methods that doesn't make any sense in this context (subList
and lastIndexOf
comes to my mind). I'd personally make the adapters implement AdapteeCollection<T>
which contains all the methods that can be delegated to the inner collection.
What do you think?
Most of the time, the adapter is being used as a list due to the last changes in the Android list widgets API and to avoid references to the collection inside the adapter. With RecyclerView now you can insert/remove one item given a position and that's needed to perform some optimizations related to the RecyclerView
draw cycle. If you want we can fix just the issue you've noticed and create another issue to review the RVRendererAdapter
interface later.
Fixed by @Serchinastico