In an MVP template, should adapters hold models or should facilitators hold models and have the adapter referenced?

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);
    // bind model to view holder
}

@Override
public int getItemCount() {
    return presenter.getModels().size();
}


}

Thus, when Presenter selects more models, it simply calls getAdapter().notfiyDataSetChanged();after retrieval.

+4
source share
2 answers

. , , , , , , , .

, generics, recyclerview. CRUD (, , , ..). , . /, .

CRUD , . , recyclerviews, , , .

+4

.

. .

- . Presenter, , ..

, :

→ → → - > Item

, .

.

+3

All Articles