Java 类com.facebook.drawee.controller.AbstractDraweeController 实例源码

项目:GitHub    文件:ImageFormatOverrideExample.java   
@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);
}
项目:GitHub    文件:DraweeMocks.java   
/**
 * 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;
}
项目:GitHub    文件:ZoomableDraweeView.java   
@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);
}
项目:fresco    文件:DraweeMocks.java   
/**
 * 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;
}
项目:fresco    文件:ZoomableDraweeView.java   
@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);
}
项目:fresco    文件:ImageFormatOverrideExample.java   
@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);
}
项目:S1-Go    文件:ImageLoader.java   
public void displayImage(String imageUri, ImageView imageView, ImageLoadingListener listener) {
    if (TextUtils.isEmpty(imageUri)) return;

    if (imageView instanceof GenericDraweeView) {
        if (listener != null) {
            PipelineDraweeControllerBuilder builder = Fresco.newDraweeControllerBuilder();
            ImageLoaderListener listener1 = new ImageLoaderListener();
            listener1.setData(listener, imageUri, imageView);
            ImageRequest request = ImageRequestBuilder.newBuilderWithSource(Uri.parse(imageUri)).build();
            AbstractDraweeController controller = builder.setOldController(((GenericDraweeView) imageView).getController()).setControllerListener(listener1).setImageRequest(request).build();
            ((GenericDraweeView) imageView).setController(controller);
            return;
        }
    }
    imageView.setImageURI(Uri.parse(imageUri));
}
项目:apps-android-wikipedia    文件:ZoomableDraweeView.java   
@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);
}
项目:GitHub    文件:DraweeMocks.java   
/**
 * 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;
}
项目:GitHub    文件:DraweeSpanStringBuilder.java   
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);
}
项目:MyAndroidTest    文件:GiftAnimationView.java   
private void prepareFrontground(String frontWebpName) {
    if (!TextUtils.isEmpty(frontWebpName)) {
        File backWebp = new File("/sdcard/sololive/effect/ship3", frontWebpName);
        ImageRequest localImageRequest = ImageRequestBuilder.newBuilderWithSource(Uri.fromFile(backWebp)).build();
        AbstractDraweeController localAbstractDraweeController = Fresco.newDraweeControllerBuilder().setOldController(mFrontAnimView.getController()).setImageRequest(localImageRequest).setAutoPlayAnimations(true).build();
        mFrontAnimView.setController(localAbstractDraweeController);
    }
}
项目:MyAndroidTest    文件:GiftAnimParser.java   
public static boolean prepareBg(SimpleDraweeView bgImage, String bgFileName) {
    if (!TextUtils.isEmpty(bgFileName)) {
        File bgFile = new File("/sdcard/sololive/effect/ship3", bgFileName);
        Log.e(TAG, "bgFile=" + bgFile.getAbsolutePath());
        if (bgFile.exists()) {
            if (FileUtils.isWebpFile(bgFileName)) {
                Log.e(TAG, "isWebp File");
                ImageRequest localImageRequest = ImageRequestBuilder.newBuilderWithSource(Uri.fromFile(bgFile)).build();
                Log.e(TAG, "simpledrawee=" + bgImage.hashCode());
                ControllerListener controllerListener = new BaseControllerListener<ImageInfo>() {
                    @Override
                    public void onFinalImageSet(
                            String id,
                            @Nullable ImageInfo imageInfo,
                            @Nullable Animatable anim) {
                        Log.e(TAG, "onFinalImageSet");
                        if (anim != null) {
                            // app-specific logic to enable animation starting
                            anim.start();
                        }
                    }

                };

                AbstractDraweeController localAbstractDraweeController = Fresco
                        .newDraweeControllerBuilder()
                        .setOldController(bgImage.getController())
                        .setControllerListener(controllerListener)
                        .setImageRequest(localImageRequest)
                        .build();
                bgImage.setController(localAbstractDraweeController);
                return true;
            } else {
                Uri uri = Uri.fromFile(bgFile);
                bgImage.setImageURI(uri);
            }
        }
    }
    return false;
}
项目:fresco    文件:DraweeMocks.java   
/**
 * 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;
}
项目:fresco    文件:DraweeSpanStringBuilder.java   
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);
}
项目:AndroidPlayground    文件:FrescoUtil.java   
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);
}
项目:ZoomableFrescoExample    文件:MainActivity.java   
@Override
protected void onResume() {
    super.onResume();

    final AbstractDraweeController controller = Fresco.newDraweeControllerBuilder()
            .setUri(Uri.parse("https://assets-cdn.github.com/images/modules/open_graph/github-octocat.png"))
            .setOldController(imageView.getController())
            .build();

    imageView.setController(controller);
}
项目:GitHub    文件:ZoomableDraweeView.java   
private void removeControllerListener(DraweeController controller) {
  if (controller instanceof AbstractDraweeController) {
    ((AbstractDraweeController) controller)
        .removeControllerListener(mControllerListener);
  }
}
项目:GitHub    文件:ZoomableDraweeView.java   
private void addControllerListener(DraweeController controller) {
  if (controller instanceof AbstractDraweeController) {
    ((AbstractDraweeController) controller)
        .addControllerListener(mControllerListener);
  }
}
项目:Zoomable    文件:ZoomableDraweeView.java   
private void removeControllerListener(DraweeController controller) {
    if (controller instanceof AbstractDraweeController) {
        ((AbstractDraweeController) controller)
                .removeControllerListener(mControllerListener);
    }
}
项目:Zoomable    文件:ZoomableDraweeView.java   
private void addControllerListener(DraweeController controller) {
    if (controller instanceof AbstractDraweeController) {
        ((AbstractDraweeController) controller)
                .addControllerListener(mControllerListener);
    }
}
项目:CommentGallery    文件:ZoomableDraweeView.java   
private void removeControllerListener(DraweeController controller) {
    if (controller instanceof AbstractDraweeController) {
        ((AbstractDraweeController) controller)
                .removeControllerListener(mControllerListener);
    }
}
项目:CommentGallery    文件:ZoomableDraweeView.java   
private void addControllerListener(DraweeController controller) {
    if (controller instanceof AbstractDraweeController) {
        ((AbstractDraweeController) controller)
                .addControllerListener(mControllerListener);
    }
}
项目:tumbviewer    文件:ZoomableDraweeView.java   
private void removeControllerListener(DraweeController controller) {
  if (controller instanceof AbstractDraweeController) {
    ((AbstractDraweeController) controller)
        .removeControllerListener(mControllerListener);
  }
}
项目:tumbviewer    文件:ZoomableDraweeView.java   
private void addControllerListener(DraweeController controller) {
  if (controller instanceof AbstractDraweeController) {
    ((AbstractDraweeController) controller)
        .addControllerListener(mControllerListener);
  }
}
项目:FinalProject    文件:ZoomableDraweeView.java   
private void removeControllerListener(DraweeController controller) {
  if (controller instanceof AbstractDraweeController) {
    ((AbstractDraweeController) controller)
            .removeControllerListener(mControllerListener);
  }
}
项目:FinalProject    文件:ZoomableDraweeView.java   
private void addControllerListener(DraweeController controller) {
  if (controller instanceof AbstractDraweeController) {
    ((AbstractDraweeController) controller)
            .addControllerListener(mControllerListener);
  }
}
项目:materialup    文件:ZoomableDraweeView.java   
private void removeControllerListener(DraweeController controller) {
    if (controller instanceof AbstractDraweeController) {
        ((AbstractDraweeController) controller)
                .removeControllerListener(mControllerListener);
    }
}
项目:materialup    文件:ZoomableDraweeView.java   
private void addControllerListener(DraweeController controller) {
    if (controller instanceof AbstractDraweeController) {
        ((AbstractDraweeController) controller)
                .addControllerListener(mControllerListener);
    }
}
项目:gank-examples    文件:MyPhotoView.java   
public void setImageUri(String uri, ResizeOptions options) {

        final ImageRequest imageRequest = ImageRequestBuilder.newBuilderWithSource(Uri.parse(uri))
                .setResizeOptions(options)
                .setAutoRotateEnabled(true)
                .build();
        final ImagePipeline imagePipeline = Fresco.getImagePipeline();
        final DataSource<CloseableReference<CloseableImage>> dataSource = imagePipeline.fetchDecodedImage(imageRequest, this);
        final AbstractDraweeController controller = Fresco.newDraweeControllerBuilder()
                .setOldController(mDraweeHolder.getController())
                .setImageRequest(imageRequest)
                .setControllerListener(new BaseControllerListener<ImageInfo>() {
                    @Override
                    public void onFinalImageSet(String id, ImageInfo imageInfo, Animatable animatable) {
                        super.onFinalImageSet(id, imageInfo, animatable);

                        CloseableReference<CloseableImage> imageCloseableReference = null;
                        try {
                            imageCloseableReference = dataSource.getResult();
                            if (imageCloseableReference != null) {
                                final CloseableImage image = imageCloseableReference.get();
                                if (image != null && image instanceof CloseableStaticBitmap) {
                                    CloseableStaticBitmap closeableStaticBitmap = (CloseableStaticBitmap) image;
                                    final Bitmap bitmap = closeableStaticBitmap.getUnderlyingBitmap();
                                    if (bitmap != null) {
                                        setImageBitmap(bitmap);
                                        // 如果是长图,让其宽度放大至与屏幕等宽
                                        setScaleType(ScaleType.CENTER_CROP);
                                    }
                                }
                            }
                        } finally {
                            dataSource.close();
                            CloseableReference.closeSafely(imageCloseableReference);
                        }
                    }
                })
                .build();
        mDraweeHolder.setController(controller);
        setImageDrawable(mDraweeHolder.getTopLevelDrawable());
    }
项目:FrescoUtils    文件:ZoomableDraweeView.java   
private void removeControllerListener(DraweeController controller) {
  if (controller instanceof AbstractDraweeController) {
    ((AbstractDraweeController) controller)
            .removeControllerListener(mControllerListener);
  }
}
项目:FrescoUtils    文件:ZoomableDraweeView.java   
private void addControllerListener(DraweeController controller) {
  if (controller instanceof AbstractDraweeController) {
    ((AbstractDraweeController) controller)
            .addControllerListener(mControllerListener);
  }
}
项目:zSMTH-Android    文件:MyPhotoView.java   
public void setImageUri(String uri) {

    final ImageRequest imageRequest =
        ImageRequestBuilder.newBuilderWithSource(Uri.parse(uri)).setResizeOptions(null).setAutoRotateEnabled(true).build();
    final ImagePipeline imagePipeline = Fresco.getImagePipeline();
    final DataSource<CloseableReference<CloseableImage>> dataSource = imagePipeline.fetchDecodedImage(imageRequest, this);
    final AbstractDraweeController controller = Fresco.newDraweeControllerBuilder()
        .setOldController(mDraweeHolder.getController())
        .setAutoPlayAnimations(true)
        .setImageRequest(imageRequest)
        .setControllerListener(new BaseControllerListener<ImageInfo>() {
          @Override public void onFinalImageSet(String id, ImageInfo imageInfo, Animatable animatable) {
            super.onFinalImageSet(id, imageInfo, animatable);

            // set flag if this is an animated image
            if (animatable != null) {
              isAnimation = true;
            }

            CloseableReference<CloseableImage> imageCloseableReference = null;
            try {
              imageCloseableReference = dataSource.getResult();
              if (imageCloseableReference != null) {
                final CloseableImage image = imageCloseableReference.get();
                if (image != null && image instanceof CloseableStaticBitmap) {
                  CloseableStaticBitmap closeableStaticBitmap = (CloseableStaticBitmap) image;
                  final Bitmap bitmap = closeableStaticBitmap.getUnderlyingBitmap();
                  if (bitmap != null) {
                    setImageBitmap(bitmap);
                  }
                }
              }
            } finally {
              dataSource.close();
              CloseableReference.closeSafely(imageCloseableReference);
            }
          }
        })
        .build();
    mDraweeHolder.setController(controller);
    setImageDrawable(mDraweeHolder.getTopLevelDrawable());
  }
项目:MyAndroidTest    文件:GiftAnimationView.java   
private void prepareBackground(String backWebpName) {
    if (!TextUtils.isEmpty("kiss3")) {
        File backWebp = new File("/sdcard/sololive/effect/kiss3", "kiss.webp");
        ImageRequest localImageRequest = ImageRequestBuilder.newBuilderWithSource(Uri.fromFile(backWebp)).build();
        ControllerListener controllerListener = new BaseControllerListener<ImageInfo>() {
            @Override
            public void onFinalImageSet(
                    String id,
                    @Nullable ImageInfo imageInfo,
                    @Nullable Animatable anim) {
                Log.e(TAG, "onFinalImageSet");
                if (anim != null) {
                    // app-specific logic to enable animation starting
                    anim.start();
                }
            }

        };
        AbstractDraweeController localAbstractDraweeController = Fresco
                .newDraweeControllerBuilder()
                .setOldController(mBackAnimView.getController())
                .setImageRequest(localImageRequest)
                .setControllerListener(controllerListener)
                // .setAutoPlayAnimations(true)
                .build();


        mBackAnimView.setController(localAbstractDraweeController);

        postDelayed(new Runnable() {
            @Override
            public void run() {
                Animatable animation = mBackAnimView.getController().getAnimatable();
                if (animation != null) {
                    // 开始播放
                    animation.start();
                    // 一段时间之后,根据业务逻辑,停止播放
                   // animation.stop();
                }
            }
        },12000);
    }
}
项目:droidddle    文件:ZoomableDraweeView.java   
private void removeControllerListener(DraweeController controller) {
    if (controller instanceof AbstractDraweeController) {
        ((AbstractDraweeController) controller)
                .removeControllerListener(mControllerListener);
    }
}
项目:droidddle    文件:ZoomableDraweeView.java   
private void addControllerListener(DraweeController controller) {
    if (controller instanceof AbstractDraweeController) {
        ((AbstractDraweeController) controller)
                .addControllerListener(mControllerListener);
    }
}
项目:ZoomableDraweeView-sample    文件:ZoomableDraweeView.java   
private void removeControllerListener(DraweeController controller) {
  if (controller instanceof AbstractDraweeController) {
    ((AbstractDraweeController) controller)
        .removeControllerListener(mControllerListener);
  }
}
项目:ZoomableDraweeView-sample    文件:ZoomableDraweeView.java   
private void addControllerListener(DraweeController controller) {
  if (controller instanceof AbstractDraweeController) {
    ((AbstractDraweeController) controller)
        .addControllerListener(mControllerListener);
  }
}
项目:android-mg-bootstrap    文件:ZoomableDraweeView.java   
private void removeControllerListener(DraweeController controller) {
  if (controller instanceof AbstractDraweeController) {
    ((AbstractDraweeController) controller)
        .removeControllerListener(mControllerListener);
  }
}
项目:android-mg-bootstrap    文件:ZoomableDraweeView.java   
private void addControllerListener(DraweeController controller) {
  if (controller instanceof AbstractDraweeController) {
    ((AbstractDraweeController) controller)
        .addControllerListener(mControllerListener);
  }
}
项目:fresco    文件:ZoomableDraweeView.java   
private void removeControllerListener(DraweeController controller) {
  if (controller instanceof AbstractDraweeController) {
    ((AbstractDraweeController) controller)
        .removeControllerListener(mControllerListener);
  }
}