Actions
Utility class for building and executing Runnable actions on the main thread, with support for arguments and delays.
Constructors
JAVA
Actions action = new Actions();
Methods
Actions build(Runnable runnable)
Assigns the action target statement block.
Actions setArg(Object arg)
Sets an internal argument inside the built Runnable instance.
Object getArg()
Returns the internal argument. Must be cast to the expected object reference type.
void execute()
Executes the defined Runnable callback.
void executeDelayed(int delay)
Executes the defined Runnable callback after a set duration. The parameter delay accepts values in milliseconds.
Usage Example
JAVA
Actions action = new Actions()
.setArg("Hello from inside action thread!")
.build(() -> {
String msg = (String) action.getArg();
Log.d("TAG", msg);
});
action.executeDelayed(1500); // runs on main thread after 1.5 seconds