pass last execution time to triggers

This commit is contained in:
Milos Kozak 2019-04-16 23:52:30 +02:00
parent 4ae7efc75f
commit a828bcba53
6 changed files with 17 additions and 5 deletions

View file

@ -201,6 +201,7 @@ public class AutomationPlugin extends PluginBase {
}
});
}
event.getTrigger().executed(DateUtil.now());
}
}

View file

@ -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();

View file

@ -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);

View file

@ -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;

View file

@ -214,7 +214,7 @@ public class TriggerRecurringTime extends Trigger {
}
@Override
void notifyAboutRun(long time) {
public void executed(long time) {
lastRun = time;
}

View file

@ -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;
}