com.facebook.drawee.controller.AbstractDraweeController Java Examples

The following examples show how to use com.facebook.drawee.controller.AbstractDraweeController. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: ImageFormatOverrideExample.java    From fresco with MIT License 6 votes vote down vote up
@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);
}
 
Example #2
Source File: ZoomableDraweeView.java    From fresco with MIT License 6 votes vote down vote up
@Override
protected void onDraw(Canvas canvas) {
  int saveCount = canvas.save();
  canvas.concat(mZoomableController.getTransform());
  try {
    super.onDraw(canvas);
  } catch (Exception e) {
    DraweeController controller = getController();
    if (controller != null && controller instanceof AbstractDraweeController) {
      Object callerContext = ((AbstractDraweeController) controller).getCallerContext();
      if (callerContext != null) {
        throw new RuntimeException(
            String.format("Exception in onDraw, callerContext=%s", callerContext.toString()), e);
      }
    }
    throw e;
  }
  canvas.restoreToCount(saveCount);
}
 
Example #3
Source File: DraweeMocks.java    From fresco with MIT License 6 votes vote down vote up
/**
 * 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;
}
 
Example #4
Source File: FrescoUtil.java    From AndroidPlayground with MIT License 5 votes vote down vote up
public static void loadWithSize(ShapedDraweeView draweeView, Uri uri, int width, int height) {
    ImageRequest request = ImageRequestBuilder.newBuilderWithSource(uri)
            .setResizeOptions(new ResizeOptions(width, height))
            .setProgressiveRenderingEnabled(true)
            .setAutoRotateEnabled(true)
            .build();
    AbstractDraweeController controller = Fresco.newDraweeControllerBuilder()
            .setImageRequest(request)
            .setAutoPlayAnimations(true)
            .build();
    draweeView.setController(controller);
}
 
Example #5
Source File: FrescoController.java    From base-module with Apache License 2.0 5 votes vote down vote up
/**
 * 加载图片到 View 上,可设置回调监听
 * @param draweeView
 * @param listener
 */
public void intoTarget(SimpleDraweeView draweeView, ControllerListener listener) {
    if ((mImageConfig != null && mImageConfig.useNewHierarchy) || !draweeView.hasHierarchy()) {
        GenericDraweeHierarchy hierarchy = GenericDraweeHierarchyBuilder
                .newInstance(draweeView.getResources()).build();
        draweeView.setHierarchy(hierarchy);
    }
    parseImageConfig(draweeView.getHierarchy());
    if (mUri != null) {
        ImageDecodeOptions imageDecodeOptions = ImageDecodeOptions.newBuilder()
                .setDecodePreviewFrame(true)
                .build();
        ImageRequestBuilder builder = ImageRequestBuilder.newBuilderWithSource(mUri)
                .setProgressiveRenderingEnabled(true)
                .setImageDecodeOptions(imageDecodeOptions);
        if (mWidth > 0 && mHeight > 0) {
            builder.setResizeOptions(new ResizeOptions(mWidth, mHeight));
        } else {
            int width = draweeView.getMeasuredWidth();
            int height = draweeView.getMeasuredHeight();
            if(width > 0 && height > 0){
                builder.setResizeOptions(new ResizeOptions(width, height));
            }
        }

        ImageRequest request = builder.build();
        AbstractDraweeController controller = Fresco.newDraweeControllerBuilder()
                .setImageRequest(request)
                .setControllerListener(listener)
                .setOldController(draweeView.getController())
                .setAutoPlayAnimations(true)
                .build();
        draweeView.setController(controller);
    } else {
        draweeView.setImageURI("");
    }
}
 
Example #6
Source File: DraweeSpanStringBuilder.java    From fresco with MIT License 5 votes vote down vote up
public void setImageSpan(
    DraweeHolder draweeHolder,
    int startIndex,
    int endIndex,
    final int drawableWidthPx,
    final int drawableHeightPx,
    boolean enableResizing,
    @BetterImageSpan.BetterImageSpanAlignment int verticalAlignment) {
  if (endIndex >= length()) {
    // Unfortunately, some callers use this wrong. The original implementation also swallows
    // an exception if this happens (e.g. if you tap on a video that has a minutiae as well.
    // 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);
}
 
Example #7
Source File: DraweeMocks.java    From fresco with MIT License 5 votes vote down vote up
/**
 * Creates a mock DraweeController with some methods stubbed.
 *
 * @return mock DraweeController
 */
public static DraweeController mockController() {
  DraweeController controller = mock(AbstractDraweeController.class);
  stubGetAndSetHierarchy(controller);
  stubGetAndSetContentDescription(controller);
  return controller;
}
 
Example #8
Source File: ZoomableDraweeView.java    From droidddle with Apache License 2.0 4 votes vote down vote up
private void addControllerListener(DraweeController controller) {
    if (controller instanceof AbstractDraweeController) {
        ((AbstractDraweeController) controller)
                .addControllerListener(mControllerListener);
    }
}
 
Example #9
Source File: ZoomableDraweeView.java    From fresco with MIT License 4 votes vote down vote up
private void addControllerListener(DraweeController controller) {
  if (controller instanceof AbstractDraweeController) {
    ((AbstractDraweeController) controller).addControllerListener(mControllerListener);
  }
}
 
Example #10
Source File: ZoomableDraweeView.java    From fresco with MIT License 4 votes vote down vote up
private void removeControllerListener(DraweeController controller) {
  if (controller instanceof AbstractDraweeController) {
    ((AbstractDraweeController) controller).removeControllerListener(mControllerListener);
  }
}
 
Example #11
Source File: ZoomableDraweeView.java    From ZoomableDraweeView-sample with Apache License 2.0 4 votes vote down vote up
private void addControllerListener(DraweeController controller) {
  if (controller instanceof AbstractDraweeController) {
    ((AbstractDraweeController) controller)
        .addControllerListener(mControllerListener);
  }
}
 
Example #12
Source File: ZoomableDraweeView.java    From ZoomableDraweeView-sample with Apache License 2.0 4 votes vote down vote up
private void removeControllerListener(DraweeController controller) {
  if (controller instanceof AbstractDraweeController) {
    ((AbstractDraweeController) controller)
        .removeControllerListener(mControllerListener);
  }
}
 
Example #13
Source File: ZoomableDraweeView.java    From imsdk-android with MIT License 4 votes vote down vote up
private void removeControllerListener(DraweeController controller) {
  if (controller instanceof AbstractDraweeController) {
    ((AbstractDraweeController) controller)
        .removeControllerListener(mControllerListener);
  }
}
 
Example #14
Source File: ZoomableDraweeView.java    From droidddle with Apache License 2.0 4 votes vote down vote up
private void removeControllerListener(DraweeController controller) {
    if (controller instanceof AbstractDraweeController) {
        ((AbstractDraweeController) controller)
                .removeControllerListener(mControllerListener);
    }
}
 
Example #15
Source File: ZoomableDraweeView.java    From FrescoUtils with Apache License 2.0 4 votes vote down vote up
private void addControllerListener(DraweeController controller) {
  if (controller instanceof AbstractDraweeController) {
    ((AbstractDraweeController) controller)
            .addControllerListener(mControllerListener);
  }
}
 
Example #16
Source File: ZoomableDraweeView.java    From FrescoUtils with Apache License 2.0 4 votes vote down vote up
private void removeControllerListener(DraweeController controller) {
  if (controller instanceof AbstractDraweeController) {
    ((AbstractDraweeController) controller)
            .removeControllerListener(mControllerListener);
  }
}
 
Example #17
Source File: ZoomableDraweeView.java    From materialup with Apache License 2.0 4 votes vote down vote up
private void addControllerListener(DraweeController controller) {
    if (controller instanceof AbstractDraweeController) {
        ((AbstractDraweeController) controller)
                .addControllerListener(mControllerListener);
    }
}
 
Example #18
Source File: ZoomableDraweeView.java    From materialup with Apache License 2.0 4 votes vote down vote up
private void removeControllerListener(DraweeController controller) {
    if (controller instanceof AbstractDraweeController) {
        ((AbstractDraweeController) controller)
                .removeControllerListener(mControllerListener);
    }
}
 
Example #19
Source File: ZoomableDraweeView.java    From CommentGallery with Apache License 2.0 4 votes vote down vote up
private void addControllerListener(DraweeController controller) {
    if (controller instanceof AbstractDraweeController) {
        ((AbstractDraweeController) controller)
                .addControllerListener(mControllerListener);
    }
}
 
Example #20
Source File: ZoomableDraweeView.java    From CommentGallery with Apache License 2.0 4 votes vote down vote up
private void removeControllerListener(DraweeController controller) {
    if (controller instanceof AbstractDraweeController) {
        ((AbstractDraweeController) controller)
                .removeControllerListener(mControllerListener);
    }
}
 
Example #21
Source File: ZoomableDraweeView.java    From imsdk-android with MIT License 4 votes vote down vote up
private void addControllerListener(DraweeController controller) {
  if (controller instanceof AbstractDraweeController) {
    ((AbstractDraweeController) controller)
        .addControllerListener(mControllerListener);
  }
}