FileDocCategorySizeDatePackage
BroadcastDispatcher.javaAPI DocAndroid 5.1 API2084Thu Mar 12 22:22:10 GMT 2015android.hardware.camera2.dispatch

BroadcastDispatcher

public class BroadcastDispatcher extends Object implements Dispatchable
Broadcast a single dispatch into multiple other dispatchables.

Every time {@link #dispatch} is invoked, all the broadcast targets will see the same dispatch as well. The first target's return value is returned.

This enables a single listener to be converted into a multi-listener.

Fields Summary
private final List
mDispatchTargets
Constructors Summary
public BroadcastDispatcher(Dispatchable dispatchTargets)
Create a broadcast dispatcher from the supplied dispatch targets.

param
dispatchTargets one or more targets to dispatch to

        mDispatchTargets = Arrays.asList(
                checkNotNull(dispatchTargets, "dispatchTargets must not be null"));
    
Methods Summary
public java.lang.Objectdispatch(java.lang.reflect.Method method, java.lang.Object[] args)

        Object result = null;
        boolean gotResult = false;

        for (Dispatchable<T> dispatchTarget : mDispatchTargets) {
            Object localResult = dispatchTarget.dispatch(method, args);

            if (!gotResult) {
                gotResult = true;
                result = localResult;
            }
        }

        return result;