Is it a good pattern design for DI to pass activity instead of context, or should I pass activity context instead and cast it to activity
The main purpose of passing activity is to use the listener in MVC architecture
@ActivityScoped
public class EMRTDUseCase {
//Pass context only when strictly necessary for UI-related tasks or starting other UI components.
@Inject
public EMRTDUseCase(AppCompatActivity activity, SharedPref sharedPreferences) {
this.activiy = activity;
this.sharedPref = sharedPreferences;
}
public void initEMRTDReadTask(String docNumber) {
EmrtdReadTask readTask =
new EmrtdReadTask(
)
readTask.setTaskListener((EmrtdReadTaskListener) activiy);
activiy.getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
}
}
}