Last active
August 29, 2015 14:09
-
-
Save rogerpujol/4200b1b7018d577e57f8 to your computer and use it in GitHub Desktop.
Android Listen for events between classes
This file contains hidden or 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 MyClass1{ | |
public MyClass2 mMC2; | |
public MyClass1(){ | |
mMC2.setOnAnimationEndedListener(new MyClass2.OnAnimationEndedListener() { | |
@Override | |
public void onAnimationEnded() { | |
Log.v("TAG", "onAnimationEndedListener"); | |
} | |
}); | |
} | |
} |
This file contains hidden or 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 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