Last active
April 19, 2021 08:48
-
-
Save pfmaggi/e28dfd937fa2efec37721d6edeedc4ea to your computer and use it in GitHub Desktop.
Code for the Medium article: "Customizing WorkManager"
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: UpvoteStoryHttpApi) : WorkerFactory() { | |
override fun createWorker( | |
appContext: Context, | |
workerClassName: String, | |
workerParameters: WorkerParameters | |
): ListenableWorker? { | |
// This only handles a single Worker, please don’t do this!! | |
// See below for a better way using DelegatingWorkerFactory | |
return UpvoteStoryWorker(appContext, workerParameters, DesignerNewsService) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment