Last active
August 29, 2015 14:15
-
-
Save johnhiott/9e511b278d3e597bc05f to your computer and use it in GitHub Desktop.
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 ChildClass { | |
private List<Callback> callbacks; | |
@UiHandler AcceptButton | |
void onClick(){ | |
for (Callback callback : callbacks) { | |
callback.Accept() | |
} | |
} | |
@UiHandler DeclineButton | |
void onClick() { | |
for (Callback callback : callbacks) { | |
callback.decline | |
} | |
} | |
public void addCallback(Callback callback) { | |
callbacks.add(callback); | |
} | |
public interface Callback { | |
void accept(); | |
void decline(); | |
} | |
} | |
public class ParentClass() { | |
private ChildClass mChildClass; | |
private void init() { | |
mChildClass.addCallback(acceptCallback); | |
mChildClass.addCallback(declineCallback); | |
} | |
Callback acceptCallback = new Callback() { | |
@Override | |
void accept() { | |
dosomething; | |
} | |
@Override | |
void decline() { | |
//do nothing | |
} | |
} | |
Callback declineCallback = new Callback() { | |
@Override | |
void accept() { | |
//do nothing | |
} | |
@Override | |
void decline() { | |
dosomethingelse(); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment