In RecyclerView I have a ViewHolder
with VideoView and Button
"Like" with the state (selected or not).
My Presenter have a method which will update "Like" status in the model - VideoEntity.
In callback I need to update View form Presenter, so I call getView().updateItem(VideoEntity entity)
.
After that, I should find recyclerView entity position, and invalidate item.
So I want to avoid that.
In classic architecture, i can call some method from ViewHolder
, get some callback there and update changed data.
How to migrate this pseudo-code to MVP pattern?
@Override
public void onBindViewHolder(ContainerViewHolder holder, int position) {
...
rx.subscribe(result -> holder.update(result));
}
@Override
public void onViewRecycled(ContainerViewHolder holder) {
if (haveBackgroundRequests) { rx.unsubscribe(holder); }
}
One presenter for one viewHolder. I found solution here: https://github.com/remind101/android-arch-sample