Good question!
Craig Russell

Can you please let me know how to use Dagger when instantiating Presenter with injected parameters in the attachPresenter()? In my activity class, I am doing,

@Inject PlacesListPresenter presenter;
protected void onCreate(@Nullable Bundle savedInstanceState) {
((BaseApplication) getApplication()).getApplicationComponent().inject(this);
// ...
private void attachPresenter() {
presenter = (PlacesListPresenter) getLastCustomNonConfigurationInstance();
if (presenter == null) {
presenter = new PlacesListPresenter(param1, param2);

The param1 and param2 parameters are placeholders that are injected via constructor in the presenter class only.

public PlacesListPresenter(PlacesListUseCaseImpl placesListUseCase, DatabaseManager databaseManager) {...}

I don’t want to inject the usecase and database manger in the activity class in order to replace the params.

Basically, my question is how to replace the creating new Presenter(x,y) by using dagger injection @Inject presenter.

Like what you read? Give Prabin Timsina a round of applause.

From a quick cheer to a standing ovation, clap to show how much you enjoyed this story.