dvdciri / MultiChoiceRecyclerView

Multi choice selection applied on recycler view make life easier

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Use this lib with nested adapter

hardysim opened this issue · comments

I want to use this lib with a nested adapter (which provides section-headers). Because of this, I have currently two adapters (SimpleSectionedRecyclerViewAdapter and the actual ListAdapter).

Because only the SectionAdapter is provided in MultiChoiceRecyclerView#setAdapter(), the nested adapter produces an error (listener not set) in MultiChoiceAdapter#onBindViewHolder() (it extends MultiChoiceAdapter as well so the actual items are covered by this lib).

When I got it right, the listener is set in MultiChoiceRecyclerView#setAdapter() - but this is only called for the SectionedAdapter.


I tried to delegate the setMultiChoiceListener()-call to the nested-adapter but this is currently not possible because this method and its parameter are package-local.

Can we get this both public so I can override it? Is there a better way to get a nested adapter working?

The SelectionListener is package-protected because it should only be used internally in the MultiChoiceRecyclerView along with the MultiChoiceAdapter#setMultiChoiceListener method.

Just to understand, you have a ListAdapter that is extending the MultiChoiceAdapter, in this case you shouldn't have any problem with that as long as you're calling the super.onBindViewHolder(holder, position).

If that's not the case, please give more details about the issue because the MultiChoiceAdapter is created on purpose to be the extension of other adapters.

Anyway, there will be a major release that will remove completely the MultiChoiceRecyclerView in order to simplify the implementation of the library just with the adapter (This ends up removing the SelectionListener as well), so you shouldn't have any issue at that point.

I'm not using the ListAdapter directly / it's not added to the RecyclerView. What is added, is SimpleSectionedRecyclerViewAdapter (which adds SectionHeaders and delegates calls to ListAdapter when needed).

Because of this, only one of the two adapters is called as a parameter in MultiChoiceRecyclerView#setAdapter() and therefore I get a crash in the inner one.


The next release sounds good. Any release date yet?

I'm thinking or releasing v1.1.14 really really soon (like in days), that is the updated version for the current develop branch with a bunch of performance improvements and bugfix, and then push out a 2.0.0 with the major changes removing the custom RecyclerView.

I can't really specify any date for that but I'm gonna create a milestone with an issue in order to give updates on that progress.

Hope that will be helpful.

Closing, following with #22.