Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Java Runnable With Arg
public interface RunnableWithArg<T> {
* Similar to the runnable interface but it accepts an argument
* @param arg any type of argument
public void run(T arg);

This comment has been minimized.

Copy link
Owner Author

@jsfan3 jsfan3 commented May 8, 2019

Example of usage

Suppose to have a method like the following that needs a RunnableWithArg as callback:


in this case, the implementation of getTakeAvatarCallback() can start with:

     * Callback for taking a new avatar photo from Camera or Gallery
     * @return 
    private RunnableWithArg<Image> getTakeAvatarCallback() {
       return new RunnableWithArg<Image>() {
           public void run(Image image) {
               // write your code here
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment