Skip to content

Instantly share code, notes, and snippets.

@hector6872
Last active September 1, 2016 10:04
Show Gist options
  • Save hector6872/75b6925977ac0c011286 to your computer and use it in GitHub Desktop.
Save hector6872/75b6925977ac0c011286 to your computer and use it in GitHub Desktop.
ManageListeners template
public void addListener(Listener listener) {
if (listeners == null) {
listeners = new ArrayList<>();
}
listeners.add(listener);
}
public void removeListener(Listener listener) {
if (listeners != null) {
int position = listeners.indexOf(listener);
if (position != -1) {
listeners.remove(position);
}
}
}
public void clearListener() {
if (listeners != null) {
listeners.clear();
listeners = null;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment