This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* Copyright 2020 Google LLC. | |
SPDX-License-Identifier: Apache-2.0 */ | |
class MyWorkerFactory(private val service: DesignerNewsService) : WorkerFactory() { | |
override fun createWorker( | |
appContext: Context, | |
workerClassName: String, | |
workerParameters: WorkerParameters | |
): ListenableWorker? { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* Copyright 2020 Google LLC. | |
SPDX-License-Identifier: Apache-2.0 */ | |
class MyApplication : Application(), Configuration.Provider { | |
override fun getWorkManagerConfiguration(): Configuration { | |
val myWorkerFactory = DelegatingWorkingFactory() | |
myWorkerFactory.addFactory(MyWorkerFactory(service)) | |
// Add here other factories that you may need in your application | |
return Configuration.Builder() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* Copyright 2020 Google LLC. | |
SPDX-License-Identifier: Apache-2.0 */ | |
@Singleton | |
class MyWorkerFactory @Inject constructor( | |
service: DesignerNewsService | |
) : DelegatingWorkerFactory() { | |
init { | |
addFactory(myWorkerFactory(service)) | |
// Add here other factories that you may need in your application | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* Copyright 2020 Google LLC. | |
SPDX-License-Identifier: Apache-2.0 */ | |
@Singleton | |
@Component(modules = [AppModule::class]) | |
interface AppComponent { | |
@Component.Factory | |
interface Factory { | |
fun create(@BindsInstance context: Context): AppComponent | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* Copyright 2020 Google LLC. | |
SPDX-License-Identifier: Apache-2.0 */ | |
class MyApplication : Application(), Configuration.Provider { | |
// other @Inject variables | |
lateinit var appComponent: AppComponent | |
override fun onCreate() { | |
super.onCreate() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* Copyright 2020 Google LLC. | |
SPDX-License-Identifier: Apache-2.0 */ | |
class MyApplication : Application(), Configuration.Provider { | |
@Inject lateinit var myWorkerFactory: MyWorkerFactory | |
... | |
override fun getWorkManagerConfiguration(): Configuration = | |
Configuration.Builder() | |
.setMinimumLoggingLevel(android.util.Log.INFO) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* Copyright 2019 Google LLC. | |
SPDX-License-Identifier: Apache-2.0 */ | |
/** | |
* A Job that refreshes the conference data in the repository (if the app is active) and | |
* in the cache (if the app is not active). | |
*/ | |
class ConferenceDataWorker( | |
ctx: Context, | |
params: WorkerParameters, | |
private val refreshEventDataUseCase: RefreshConferenceDataUseCase |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* Copyright 2019 Google LLC. | |
SPDX-License-Identifier: Apache-2.0 */ | |
class ConferenceDataWorkerFactory( | |
private val refreshEventDataUseCase: RefreshConferenceDataUseCase | |
) : WorkerFactory() { | |
override fun createWorker( | |
appContext: Context, | |
workerClassName: String, | |
workerParameters: WorkerParameters |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* Copyright 2019 Google LLC. | |
SPDX-License-Identifier: Apache-2.0 */ | |
@Singleton | |
class IoschedWorkerFactory @Inject constructor( | |
refreshConferenceDataUseCase: RefreshConferenceDataUseCase | |
) : DelegatingWorkerFactory() { | |
init { | |
addFactory(ConferenceDataWorkerFactory(refreshConferenceDataUseCase)) | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* Copyright 2019 Google LLC. | |
SPDX-License-Identifier: Apache-2.0 */ | |
@Inject lateinit var workerConfiguration: Configuration | |
// Setup custom configuration for WorkManager with a DelegatingWorkerFactory | |
override fun getWorkManagerConfiguration(): Configuration { | |
return workerConfiguration | |
} |