Back to project page trip-chain-android.
The source code is released under:
MIT License
If you think the Android project trip-chain-android 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 fi.aalto.tripchain.receivers; /*from w w w . j a v a2s . c o m*/ import java.util.ArrayList; import java.util.List; import android.location.Location; import fi.aalto.tripchain.here.Address; import fi.aalto.tripchain.route.Activity; /** * Static class used to dispatch events globally. * Currently events are dispatched only in service * context. * */ public class EventDispatcher { private static List<EventListener> listeners = new ArrayList<EventListener>(); /** * Subscribes events to listener. * @param listener */ public synchronized static void subscribe(EventListener listener) { listeners.add(listener); } /** * Removes listener's subscription. */ public synchronized void unsubscribe(EventListener listener) { listeners.remove(listener); } /** * Dispatches location event to listeners. */ public static synchronized void onLocation(Location location) { for (EventListener el : listeners) { el.onLocation(location); } } /** * Dispatches activity event to listeners. */ public static synchronized void onActivity(Activity activity) { for (EventListener el : listeners) { el.onActivity(activity); } } /** * Dispatches address event to listeners. */ public static synchronized void onAddress(Address address) { for (EventListener el : listeners) { el.onAddress(address); } } }