diff options
author | YuutaW <17158086+Trumeet@users.noreply.github.com> | 2019-02-24 11:59:17 -0800 |
---|---|---|
committer | YuutaW <17158086+Trumeet@users.noreply.github.com> | 2019-02-24 11:59:17 -0800 |
commit | a08328403be84d85c006f801169a3feed0d956a4 (patch) | |
tree | ceebece6443a3e6662a4937b911c58904bb5b1ff /app/src/main/java/moe/yuuta/workmode/async/StoppableGroup.kt | |
download | WorkMode-a08328403be84d85c006f801169a3feed0d956a4.tar WorkMode-a08328403be84d85c006f801169a3feed0d956a4.tar.gz WorkMode-a08328403be84d85c006f801169a3feed0d956a4.tar.bz2 WorkMode-a08328403be84d85c006f801169a3feed0d956a4.zip |
First Commit
Signed-off-by: YuutaW <17158086+Trumeet@users.noreply.github.com>
Diffstat (limited to 'app/src/main/java/moe/yuuta/workmode/async/StoppableGroup.kt')
-rw-r--r-- | app/src/main/java/moe/yuuta/workmode/async/StoppableGroup.kt | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/app/src/main/java/moe/yuuta/workmode/async/StoppableGroup.kt b/app/src/main/java/moe/yuuta/workmode/async/StoppableGroup.kt new file mode 100644 index 0000000..ef651fe --- /dev/null +++ b/app/src/main/java/moe/yuuta/workmode/async/StoppableGroup.kt @@ -0,0 +1,28 @@ +package moe.yuuta.workmode.async + +class StoppableGroup : Stoppable { + private val innerList: MutableList<Stoppable> = mutableListOf() + + fun add(stoppable: Stoppable): StoppableGroup { + innerList.add(stoppable) + return this + } + + fun remove(stoppable: Stoppable): StoppableGroup { + innerList.remove(stoppable) + return this + } + + override fun stop() { + innerList.stream().forEach { + it.stop() + } + } + + override fun isStopped(): Boolean { + for (stoppable in innerList) { + if (!stoppable.isStopped()) return false + } + return true + } +}
\ No newline at end of file |