Back to project page sres.
The source code is released under:
Apache License
If you think the Android project sres listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.
package me.tatarka.sres; // w w w. jav a 2 s.com import java.util.LinkedHashSet; import java.util.Set; /** * A base implementation of trackable. This implementation calls the listeners on the main thread in * the order that they were registered. * * You can subclass this and call @{link AbstractTrackable#notifyChange} when the trqckable has * changed. */ public abstract class AbstractTrackable implements Trackable { private Set<Listener> listeners = new LinkedHashSet<Listener>(); @Override public void addListener(Listener listener) { listeners.add(listener); } @Override public void removeListener(Listener listener) { listeners.remove(listener); } protected void notifyChange() { ThreadHandlerProvider.getDefault().postToMainThread(new Runnable() { @Override public void run() { for (Listener listener : listeners) listener.onChange(); } }); } }