Open MihashiHans opened 4 years ago
public void setSelectionTracker(@Nullable SelectionTracker<Long> selectionTracker) {
this.selectionTracker = selectionTracker;
}
@Override
public void onBindViewHolder(@NonNull VH holder, int position, @NonNull List<Object> payloads) {
Item contentItem = getItem(position);
if (selectionTracker != null) {
contentItem.bind(holder, position, payloads, onItemClickListener, onItemLongClickListener, selectionTracker.isSelected(contentItem.getId()));
}else {
contentItem.bind(holder, position, payloads, onItemClickListener, onItemLongClickListener, false);
}
}
@ValCanBuild Implementing this would require adding the above to GroupAdapter.java, GroupieLookup.java, GroupieViewHolder.java, Item.java. If needed I would be more than happy to come up with a PR.
Implementing this directly in the library means we'd need to depend on the recyclerview-selection
library. Would it be more prudent to add support for this via another library? A SelectableItem
subclass maybe?
Haven't played with the selection library so am not sure what the best approach for it would be - I welcome PRs, though.
Thanks a lot for this great library! Enabling selection/multiple selections is kind of tedious and it would be very nice if Groupie took care of the setup to some extent as an option. If this is a feature you would consider, I'd be happy to give it a try.