Created
November 20, 2018 19:38
-
-
Save jdsingh/9ed1c4c7d51e0f36fe3e2194d8132066 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
class LocationWorker( | |
context: Context, | |
params: WorkerParameters | |
) : ListenableWorker(context, params) { | |
private val future: ResolvableFuture<Payload> = ResolvableFuture.create() | |
override fun startWork(): ListenableFuture<Payload> { | |
if (hasLocationPermission()) { | |
getLocation(getFusedLocationProviderClient().lastLocation) | |
} else { | |
future.set(Payload(Result.FAILURE)) | |
} | |
return future | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment