我想以这种方式使用依赖注入。
public class UsersActivity extends AppCompatActivity implements MvpUsers.View {
private MvpUsers.Presenter presenter;
RecyclerView rvUsers;
@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_users);
rvUsers=findViewById(R.id.rvUsers);
presenter=UsersPresenter.getInstance();
}
@Override
protected void onResume() {
super.onResume();
presenter.attach(this);
presenter.requestData();
}....}
这是主持人
public class UsersPresenter implements MvpUsers.Presenter {
public static UsersPresenter getInstance()
{
return new UsersPresenter(UsersModel.getInstance());
}
private MvpUsers.View view;
private MvpUsers.Model model;
int page=0;
int pageCount=0;
public UsersPresenter(MvpUsers.Model model){
this.model=model;
}...}
请为我的策略提供一些帮助,我想在将来使用匕首,所以我想为此做准备。我想知道giveme是否有测试麻烦。