Skip to content

Instantly share code, notes, and snippets.

@rogerpujol
Last active August 29, 2015 14:09
Show Gist options
  • Save rogerpujol/4200b1b7018d577e57f8 to your computer and use it in GitHub Desktop.
Save rogerpujol/4200b1b7018d577e57f8 to your computer and use it in GitHub Desktop.
Android Listen for events between classes
public class MyClass1{
public MyClass2 mMC2;
public MyClass1(){
mMC2.setOnAnimationEndedListener(new MyClass2.OnAnimationEndedListener() {
@Override
public void onAnimationEnded() {
Log.v("TAG", "onAnimationEndedListener");
}
});
}
}
public class MyClass2{
private OnAnimationEndedListener mAnimationListener;
public static interface OnAnimationEndedListener {
void onAnimationEnded();
}
public MyClass2(){
/**
* Calls this whenever you want MyClass1 to receive the onAnimationEnded event...
*/
mAnimationListener.onAnimationEnded();
}
public void setOnAnimationEndedListener(OnAnimationEndedListener listener){
mAnimationListener = listener;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment