Created
September 28, 2013 11:51
-
-
Save sonOfRa/6741319 to your computer and use it in GitHub Desktop.
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 interface MyCallback { | |
public void execute(); | |
} | |
public class MyConcreteCallback implements Parcelable, MyCallback { | |
public void execute() { | |
doSomething(); | |
} | |
// Parcelable stuff | |
} | |
public class MyClass { | |
protected List<MyCallback> callbacks; | |
public void onAction () { | |
for(MyCallback callback : callbacks) callback.execute(); | |
} | |
public void registerCallback(MyCallback cb) {callbacks.add(cb);} | |
} | |
public class MyAndroidClass extends MyClass implements Parcelable { | |
// Parcelable stuff | |
} | |
public class SomeActivity { | |
MyAndroidClass mac = new MyAndroidClass(); | |
mac.registerCallback(new MyConcreteCallback()); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment