Search in sources :

Example 1 with AbstractDraweeController

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;
}
Also used : Answer(org.mockito.stubbing.Answer) InvocationOnMock(org.mockito.invocation.InvocationOnMock) ControllerListener(com.facebook.drawee.controller.ControllerListener) ForwardingControllerListener(com.facebook.drawee.controller.ForwardingControllerListener) ForwardingControllerListener(com.facebook.drawee.controller.ForwardingControllerListener) AbstractDraweeController(com.facebook.drawee.controller.AbstractDraweeController)

Example 2 with AbstractDraweeController

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);
}
Also used : SimpleDraweeView(com.facebook.drawee.view.SimpleDraweeView) AbstractDraweeController(com.facebook.drawee.controller.AbstractDraweeController) ImageDecodeOptions(com.facebook.imagepipeline.common.ImageDecodeOptions) ImageDecodeOptionsBuilder(com.facebook.imagepipeline.common.ImageDecodeOptionsBuilder)

Example 3 with AbstractDraweeController

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);
}
Also used : DraweeController(com.facebook.drawee.interfaces.DraweeController) AbstractDraweeController(com.facebook.drawee.controller.AbstractDraweeController) Drawable(android.graphics.drawable.Drawable) AbstractDraweeController(com.facebook.drawee.controller.AbstractDraweeController)

Aggregations

AbstractDraweeController (com.facebook.drawee.controller.AbstractDraweeController)3 Drawable (android.graphics.drawable.Drawable)1 ControllerListener (com.facebook.drawee.controller.ControllerListener)1 ForwardingControllerListener (com.facebook.drawee.controller.ForwardingControllerListener)1 DraweeController (com.facebook.drawee.interfaces.DraweeController)1 SimpleDraweeView (com.facebook.drawee.view.SimpleDraweeView)1 ImageDecodeOptions (com.facebook.imagepipeline.common.ImageDecodeOptions)1 ImageDecodeOptionsBuilder (com.facebook.imagepipeline.common.ImageDecodeOptionsBuilder)1 InvocationOnMock (org.mockito.invocation.InvocationOnMock)1 Answer (org.mockito.stubbing.Answer)1