AutomationPlugin synchronized
This commit is contained in:
parent
69554754b7
commit
724b52e929
|
@ -200,7 +200,7 @@ class AutomationPlugin @Inject constructor(
|
||||||
}
|
}
|
||||||
|
|
||||||
aapsLogger.debug(LTag.AUTOMATION, "processActions")
|
aapsLogger.debug(LTag.AUTOMATION, "processActions")
|
||||||
val iterator = automationEvents.iterator()
|
val iterator : MutableIterator<AutomationEvent> = automationEvents.iterator()
|
||||||
while (iterator.hasNext()) {
|
while (iterator.hasNext()) {
|
||||||
val event = iterator.next()
|
val event = iterator.next()
|
||||||
if (event.isEnabled && event.shouldRun() && event.trigger.shouldRun() && event.getPreconditions().shouldRun()) {
|
if (event.isEnabled && event.shouldRun() && event.trigger.shouldRun() && event.getPreconditions().shouldRun()) {
|
||||||
|
@ -240,11 +240,13 @@ class AutomationPlugin @Inject constructor(
|
||||||
storeToSP() // save last run time
|
storeToSP() // save last run time
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Synchronized
|
||||||
fun add(event: AutomationEvent) {
|
fun add(event: AutomationEvent) {
|
||||||
automationEvents.add(event)
|
automationEvents.add(event)
|
||||||
rxBus.send(EventAutomationDataChanged())
|
rxBus.send(EventAutomationDataChanged())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Synchronized
|
||||||
fun addIfNotExists(event: AutomationEvent) {
|
fun addIfNotExists(event: AutomationEvent) {
|
||||||
for (e in automationEvents) {
|
for (e in automationEvents) {
|
||||||
if (event.title == e.title) return
|
if (event.title == e.title) return
|
||||||
|
@ -253,20 +255,24 @@ class AutomationPlugin @Inject constructor(
|
||||||
rxBus.send(EventAutomationDataChanged())
|
rxBus.send(EventAutomationDataChanged())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Synchronized
|
||||||
fun set(event: AutomationEvent, index: Int) {
|
fun set(event: AutomationEvent, index: Int) {
|
||||||
automationEvents[index] = event
|
automationEvents[index] = event
|
||||||
rxBus.send(EventAutomationDataChanged())
|
rxBus.send(EventAutomationDataChanged())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Synchronized
|
||||||
fun removeAt(index: Int) {
|
fun removeAt(index: Int) {
|
||||||
automationEvents.removeAt(index)
|
automationEvents.removeAt(index)
|
||||||
rxBus.send(EventAutomationDataChanged())
|
rxBus.send(EventAutomationDataChanged())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Synchronized
|
||||||
fun at(index: Int) = automationEvents[index]
|
fun at(index: Int) = automationEvents[index]
|
||||||
|
|
||||||
fun size() = automationEvents.size
|
fun size() = automationEvents.size
|
||||||
|
|
||||||
|
@Synchronized
|
||||||
fun swap(fromPosition: Int, toPosition: Int) {
|
fun swap(fromPosition: Int, toPosition: Int) {
|
||||||
Collections.swap(automationEvents, fromPosition, toPosition)
|
Collections.swap(automationEvents, fromPosition, toPosition)
|
||||||
rxBus.send(EventAutomationDataChanged())
|
rxBus.send(EventAutomationDataChanged())
|
||||||
|
|
Loading…
Reference in a new issue