Greetings, folks. Here RescheduleAlarmWorker and A...
# android
t
Greetings, folks. Here RescheduleAlarmWorker and AlarmWorker factories are provided by the ClockWorkerFactory class. And the issue is that the ClockWorkerFactory class only adds the first factory to its delegate when initializing itself, but it does not add the second factory.
Copy code
@HiltAndroidApp
class ClockApplication : Application(), Configuration.Provider {

    @Inject lateinit var clockWorkerFactory: ClockWorkerFactory
    override fun getWorkManagerConfiguration(): Configuration =
        Configuration.Builder()
            .setMinimumLoggingLevel(android.util.Log.DEBUG)
            .setWorkerFactory(clockWorkerFactory)
            .build()
}
@Singleton
class ClockWorkerFactory @Inject constructor(
    alarmRepository: AlarmRepository,
    scheduleAlarmManager: ScheduleAlarmManager,
    alarmNotificationHelper: AlarmNotificationHelper,
    mediaPlayerHelper: MediaPlayerHelper,
) : DelegatingWorkerFactory() {
    init {
        addFactory(RescheduleAlarmWorkerFactory(alarmRepository, scheduleAlarmManager))
        addFactory(AlarmWorkerFactory(alarmRepository, alarmNotificationHelper, mediaPlayerHelper))
    }
}
not kotlin but kotlin colored 2
a
Used named annotation to denote to hilt there are two distinct classes needs to be injected
t
can you please give me an example ?