pass last execution time to triggers
This commit is contained in:
parent
4ae7efc75f
commit
a828bcba53
|
@ -201,6 +201,7 @@ public class AutomationPlugin extends PluginBase {
|
|||
}
|
||||
});
|
||||
}
|
||||
event.getTrigger().executed(DateUtil.now());
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -89,6 +89,7 @@ public abstract class Trigger {
|
|||
|
||||
public abstract boolean shouldRun();
|
||||
|
||||
|
||||
public abstract String toJSON();
|
||||
|
||||
/*package*/ abstract Trigger fromJSON(String data);
|
||||
|
@ -99,8 +100,7 @@ public abstract class Trigger {
|
|||
|
||||
public abstract Optional<Integer> icon();
|
||||
|
||||
void notifyAboutRun(long time) {
|
||||
}
|
||||
public abstract void executed(long time);
|
||||
|
||||
public abstract Trigger duplicate();
|
||||
|
||||
|
|
|
@ -131,6 +131,10 @@ public class TriggerBg extends Trigger {
|
|||
return Optional.of(R.drawable.icon_cp_bgcheck);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void executed(long time) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Trigger duplicate() {
|
||||
return new TriggerBg(this);
|
||||
|
|
|
@ -192,6 +192,13 @@ public class TriggerConnector extends Trigger {
|
|||
return Optional.absent();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void executed(long time) {
|
||||
for (int i = 0; i < list.size(); ++i) {
|
||||
list.get(i).executed(time);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Trigger duplicate() {
|
||||
return null;
|
||||
|
|
|
@ -214,7 +214,7 @@ public class TriggerRecurringTime extends Trigger {
|
|||
}
|
||||
|
||||
@Override
|
||||
void notifyAboutRun(long time) {
|
||||
public void executed(long time) {
|
||||
lastRun = time;
|
||||
}
|
||||
|
||||
|
|
|
@ -90,7 +90,7 @@ public class TriggerTime extends Trigger {
|
|||
}
|
||||
|
||||
@Override
|
||||
void notifyAboutRun(long time) {
|
||||
public void executed(long time) {
|
||||
lastRun = time;
|
||||
}
|
||||
|
||||
|
@ -104,7 +104,7 @@ public class TriggerTime extends Trigger {
|
|||
return new TriggerTime(this);
|
||||
}
|
||||
|
||||
public long getRunAt() {
|
||||
long getRunAt() {
|
||||
return runAt;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue