我试图在Dagger 2中使用Mosby的MvpBasePresenter设置Base Presenter我有以下基本组件:
public interface BaseViewComponent<V extends BaseView, P extends BasePresenter> {
void injectView(V object);
void injectPresenter(P object);
P getPresenter();
}
使用以下BasePresenter
public class BasePresenter <V extends BaseView> extends MvpBasePresenter {
@Inject public BasePresenter () {
}
}
以及以下BaseActivity
public abstract class BaseActivity<P extends BasePresenter, C extends BaseViewComponent> extends MvpActivity implements BaseView<P> {
@Inject C mComponent;
@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
if (getViewContentId() != 0) {
setContentView(getViewContentId());
ButterKnife.bind(this);
}
}
@Override
public P createPresenter() {
return mComponent.getPresenter();
}
}
由于某种原因,即使组件getPresenter返回P,创建演示者也显示为返回类型BasePresenter而不是P类型。任何人都有任何见解?这是一个好主意吗?