Skip to content

Instantly share code, notes, and snippets.

@InsanusMokrassar
Last active April 12, 2017 17:38
Show Gist options
  • Save InsanusMokrassar/bb3e8da64d9605dd989e773fe90a2cc1 to your computer and use it in GitHub Desktop.
Save InsanusMokrassar/bb3e8da64d9605dd989e773fe90a2cc1 to your computer and use it in GitHub Desktop.
Use this for call action in different threads or after some time or other. Require RXJava library.
public class ActionCaller<T> implements Runnable {
protected final Action1<T> target;
protected final T value;
public ActionCaller(Action1<T> target, T value) {
this.target = target;
this.value = value;
}
@Override
public void run() {
if (target != null) {
Log.i(getClass().getSimpleName(), "Start action: " + target + " with value " + value);
target.call(value);
Log.i(getClass().getSimpleName(), "Complete action: " + target + " with value " + value);
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment