Привет, я пытаюсь использовать метод инъекции с кинжалом 2, и я получаю исключение нулевого указателя при использовании введенной зависимости. Я попытался удалить аннотацию @provide и извлек DialogManger в отдельный модуль здесь
@Module
открытый класс DialogManagerModule {
Context context;
public DialogManagerModule(Context context){
this.context = context;
}
@Provides
DialogManager provideDialogManager(Context context){
return new DialogManager(context);
}
@Provides
ProgressDialogInteractor provideProgressDialogInteractor(){
return new ProgressDialog();
}
@Provides
Context provideContext(){
return context;
}
}
public class DialogManager {
Context context;
ProgressDialogInteractor progressDialog;
@Inject
public void setProgressDialog(ProgressDialogInteractor progressDialog) {
this.progressDialog = progressDialog;
}
public DialogManager(Context context) {
this.context = context;
}
public void showDatePickerDialog(DatePickerDialog.OnDateSetListener listener){
Calendar calendar = Calendar.getInstance();
new DatePickerDialog(
context
, listener
, calendar.get(Calendar.YEAR)
, calendar.get(Calendar.MONTH)
, calendar.get(Calendar.DAY_OF_MONTH))
.show();
}
public void showProgressDialog(@Nullable String progressText){
progressDialog
/* .setText(progressText)
.showText()*/
.show();
}
}
и вот как я назвал компонент
component =((App) getActivity().getApplication()).getComponent()
.newPersonalInfoFragmentComponent(new PersonalInfoFragmentModule(this), new DialogManagerModule(getContext()));