Skip to content
This repository has been archived by the owner on Aug 19, 2023. It is now read-only.

Commit

Permalink
Call goAsync() while still on the mainthread.
Browse files Browse the repository at this point in the history
Fixes #6
  • Loading branch information
d4rken committed Aug 28, 2018
1 parent 861b961 commit 7485be9
Showing 1 changed file with 3 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -59,29 +59,26 @@ class LockCommandReceiver : BroadcastReceiver() {
}

private fun releaseAll() {
var async: PendingResult? = null
val async = goAsync()
lockController.acquireExclusive(Collections.emptySet())
.doOnSubscribe { async = goAsync() }
.subscribeOn(Schedulers.computation())
.doFinally { async?.finish() }
.subscribe()
}

private fun acquireSaved() {
val desired = settings.getSavedLocks()
var async: PendingResult? = null
val async = goAsync()
lockController.acquireExclusive(desired)
.doOnSubscribe { async = goAsync() }
.subscribeOn(Schedulers.computation())
.doFinally { async?.finish() }
.subscribe()
}

private fun toggle() {
var async: PendingResult? = null
val async = goAsync()
lockController.locksPub
.subscribeOn(Schedulers.computation())
.doOnSubscribe { async = goAsync() }
.compose { Lock.acquiredOnly(it) }
.firstOrError()
.flatMapCompletable {
Expand Down

0 comments on commit 7485be9

Please sign in to comment.