Skip to content

Instantly share code, notes, and snippets.

@johnhiott
Last active August 29, 2015 14:15
Show Gist options
  • Save johnhiott/9e511b278d3e597bc05f to your computer and use it in GitHub Desktop.
Save johnhiott/9e511b278d3e597bc05f to your computer and use it in GitHub Desktop.
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