use of com.facebook.drawee.controller.ForwardingControllerListener in project fresco by facebook.
the class DraweeMocks method stubControllerListener.
/**
* Stubs addControllerListener
*
* @param controller
* @return forwarding listener
*/
public static ControllerListener stubControllerListener(final DraweeController controller) {
final ForwardingControllerListener forwardingListener = new ForwardingControllerListener();
if (!(controller instanceof AbstractDraweeController)) {
return null;
}
AbstractDraweeController abstractController = (AbstractDraweeController) controller;
doAnswer(new Answer() {
@Override
public Object answer(InvocationOnMock invocation) throws Throwable {
forwardingListener.addListener((ControllerListener) invocation.getArguments()[0]);
return null;
}
}).when(abstractController).addControllerListener(any(ControllerListener.class));
return forwardingListener;
}
Aggregations