Problem Description
The app relies on manual dependency injection. As the app scales, this manual wiring creates boilerplate and makes testing difficult.
Expected Solution
Refactor the codebase to use Dagger-Hilt for automated dependency injection.
Steps to Reproduce
- Check
StocksActivity.kt and StockViewModelProviderFactory.kt to see manual repository passing.
Proposed Fix
Add Hilt Gradle plugins. Annotate the application with @HiltAndroidApp. Create a di/AppModule.kt to provide singletons of Room and Retrofit. Update ViewModels with @HiltViewModel and inject them into Fragments using by viewModels().
Concerned Files
build.gradle.kts
StocksApplication.kt
AppModule.kt (new)
- All ViewModels and Fragments
Acceptance Criteria
Problem Description
The app relies on manual dependency injection. As the app scales, this manual wiring creates boilerplate and makes testing difficult.
Expected Solution
Refactor the codebase to use Dagger-Hilt for automated dependency injection.
Steps to Reproduce
StocksActivity.ktandStockViewModelProviderFactory.ktto see manual repository passing.Proposed Fix
Add Hilt Gradle plugins. Annotate the application with
@HiltAndroidApp. Create adi/AppModule.ktto provide singletons of Room and Retrofit. Update ViewModels with@HiltViewModeland inject them into Fragments usingby viewModels().Concerned Files
build.gradle.ktsStocksApplication.ktAppModule.kt(new)Acceptance Criteria
StockViewModelProviderFactoryis completely deleted from the project.