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.

Show your support

Clapping shows how much you appreciated Prabin Timsina’s story.