I am currently using it so that the adapter has a link to all the models in it. But is it better to let the presenter simply hold the models, and the adapter can just refer to them?
So for example:
public class Adapter extends RecyclerView.Adapter<RecyclerView.ViewHolder>{
private Presenter presenter;
public Adapter(Presenter presenter){
this. presenter = presenter;
}
@Override
public void onBindViewHolder(RecyclerView.ViewHolder holder, int position) {
Model m = presenter.getModels().get(position);
}
@Override
public int getItemCount() {
return presenter.getModels().size();
}
}
Thus, when Presenter selects more models, it simply calls getAdapter().notfiyDataSetChanged();after retrieval.
source
share