Last active
April 12, 2017 17:38
-
-
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.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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