Presenter是一个抽象类,和RecyclerView.Adapter中需要实现的方法相对应,onCreateViewHolder、onBindViewHolder、onUnbindViewHolder
ViewHolder 是持有子视图的root view。其子类可扩展具体的view。
public abstract class Presenter implements FacetProvider {
//Facet用于item布局属性
private Map<Class, Object> mFacets;
public static class ViewHolder implements FacetProvider {
public final View view;
private Map<Class, Object> mFacets;
public ViewHolder(View view) {
this.view = view;
}
}
public abstract ViewHolder onCreateViewHolder(ViewGroup parent);
public abstract void onBindViewHolder(ViewHolder viewHolder, Object item);
public abstract void onUnbindViewHolder(ViewHolder viewHolder);
//...
}
PresenterSelector 也是一个抽象类,需要实现getPresenter
public abstract class PresenterSelector {
//子类去实现不同item获取不同Presenter
public abstract Presenter getPresenter(Object item);
//Presenter列表
Presenter[] getPresenters() {
return null;
}
}
网友评论