This repository has been archived by the owner on May 4, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 25
Programming Actions
Adrián Rivero edited this page May 5, 2017
·
9 revisions
Actions can be easily programmed, here is shown an action to Wait for a specific amount of time, before executing the next actions:
@ActionFor(value = "Wait")
public class WaitActionHolder {
private CountDownTimer countDownTimer;
private long countDownTime;
void init(long countDownTime) {
this.countDownTime = countDownTime;
}
void build(final Runnable Finished, final Runnable Ticked) {
countDownTimer = new CountDownTimer(countDownTime, 100) {
@Override
public void onTick(long millisUntilFinished) {
if (Ticked != null) Ticked.run();
}
@Override
public void onFinish() {
if (Finished != null) Finished.run();
}
};
}
void execute() {
countDownTimer.start();
}
}
In the code, this action will be called simply like this:
void waitAndDoSomething() {
$Wait(2500);
doSomething();
}
Each action should have the following methods:
- init: It is where the action should be initialized, can have any number of parameters.
- build: It is call to build the actions. It's parameters are the Events that the action can trigger.
- execute: It is called to execute the action. This method should have no parameter.
It is recommended to declare this methods as protected (or without modifier) in order to avoid showing this methods to the user.
-
@Field
: Indicates that the parameter should be a field in the class that is using the action. Ex. [Recollect] (https://github.com/smaugho/declex/blob/master/declex-api/src/com/dspot/declex/api/action/builtin/RecollectActionHolder.java) -
@FormattedExpression
: Marks the parameter as a formatted expression, so the Formatted Syntax can be used. Ex. $Toast -
@Assignable(value: String)
: indicates a method that will be used to assign to the parameter a value. Ex. [$ProgressDialog] (https://github.com/smaugho/declex/blob/master/declex-api/src/com/dspot/declex/api/action/builtin/ProgressDialogActionHolder.java)
The actions can have a processor to interpret the action and crate a more complex code from it.
Ex. [Recollect] (https://github.com/smaugho/declex/blob/master/declex-api/src/com/dspot/declex/api/action/builtin/RecollectActionHolder.java) and its processor RecollectActionProcessor
See Also:
Sponsored by DSpot Sp. z o.o. Contact us at info@dspot.com.pl