use of com.facebook.drawee.controller.AbstractDraweeController 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;
}
use of com.facebook.drawee.controller.AbstractDraweeController in project fresco by facebook.
the class ImageFormatOverrideExample method onViewCreated.
@Override
public void onViewCreated(View view, @Nullable Bundle savedInstanceState) {
SimpleDraweeView simpleDraweeView = (SimpleDraweeView) view.findViewById(R.id.drawee_view);
ImageDecodeOptions imageDecodeOptionsWithCustomDecoder = new ImageDecodeOptionsBuilder().setCustomImageDecoder(CUSTOM_COLOR_DECODER).build();
AbstractDraweeController controller = Fresco.newDraweeControllerBuilder().setImageRequest(ImageRequestBuilder.newBuilderWithResourceId(R.raw.custom_color1).setImageDecodeOptions(imageDecodeOptionsWithCustomDecoder).build()).build();
simpleDraweeView.setController(controller);
}
use of com.facebook.drawee.controller.AbstractDraweeController in project fresco by facebook.
the class DraweeSpanStringBuilder method setImageSpan.
public void setImageSpan(DraweeHolder draweeHolder, int startIndex, int endIndex, final int drawableWidthPx, final int drawableHeightPx, boolean enableResizing, @BetterImageSpan.BetterImageSpanAlignment int verticalAlignment) {
if (endIndex >= length()) {
// Example: Text = "ABC", insert image at position 18.
return;
}
Drawable topLevelDrawable = draweeHolder.getTopLevelDrawable();
if (topLevelDrawable != null) {
if (topLevelDrawable.getBounds().isEmpty()) {
topLevelDrawable.setBounds(0, 0, drawableWidthPx, drawableHeightPx);
}
topLevelDrawable.setCallback(mDrawableCallback);
}
DraweeSpan draweeSpan = new DraweeSpan(draweeHolder, verticalAlignment);
final DraweeController controller = draweeHolder.getController();
if (controller instanceof AbstractDraweeController) {
((AbstractDraweeController) controller).addControllerListener(new DrawableChangedListener(draweeSpan, enableResizing, drawableHeightPx));
}
mDraweeSpans.add(draweeSpan);
setSpan(draweeSpan, startIndex, endIndex + 1, SPAN_EXCLUSIVE_EXCLUSIVE);
}
Aggregations