Java Code Examples for com.facebook.drawee.generic.GenericDraweeHierarchy#setActualImageScaleType()

The following examples show how to use com.facebook.drawee.generic.GenericDraweeHierarchy#setActualImageScaleType() . 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: ImageFrescoContentCell.java    From YcShareElement with Apache License 2.0 5 votes vote down vote up
@Override
protected void onBindViewHolder(BasePagerViewHolder viewHolder) {
    Fresco.getImagePipeline().evictFromCache(Uri.parse(mData.url));
    SimpleDraweeView imageView = viewHolder.getView(R.id.content_item_img);
    ViewCompat.setTransitionName(imageView, mData.url);
    Bitmap thumbnail = mData.url.equals(BitmapThumbnail.sKey)?BitmapThumbnail.sBitmap:null;
    GenericDraweeHierarchy hierarchy = imageView.getHierarchy();
    hierarchy.setPlaceholderImage(new BitmapDrawable(imageView.getResources(),thumbnail), ScalingUtils.ScaleType.FIT_CENTER);
    hierarchy.setActualImageScaleType(ScalingUtils.ScaleType.FIT_CENTER);
    imageView.setImageURI(mData.url);
}
 
Example 2
Source File: ImageLoaderManager.java    From AdPlayBanner with Apache License 2.0 5 votes vote down vote up
/**
 * Fresco设置ScaleType
 * @param context     上下文
 * @param mFrescoView 图片
 */
private void frescoViewSetScaleType(Context context, SimpleDraweeView mFrescoView){
    if (context == null || mFrescoView == null) {
        return;
    }
    GenericDraweeHierarchyBuilder builder = new GenericDraweeHierarchyBuilder(context.getResources());
    GenericDraweeHierarchy hierarchy = builder.build();
    mFrescoView.setHierarchy(hierarchy);
    switch (mScaleType) {
        default:
        case FIT_XY:
            hierarchy.setActualImageScaleType(ScalingUtils.ScaleType.FIT_XY);
            break;
        case FIT_START:
            hierarchy.setActualImageScaleType(ScalingUtils.ScaleType.FIT_START);
            break;
        case FIT_CENTER:
            hierarchy.setActualImageScaleType(ScalingUtils.ScaleType.FIT_CENTER);
            break;
        case FIT_END:
            hierarchy.setActualImageScaleType(ScalingUtils.ScaleType.FIT_END);
            break;
        case CENTER:
            hierarchy.setActualImageScaleType(ScalingUtils.ScaleType.CENTER);
            break;
        case CENTER_CROP:
            hierarchy.setActualImageScaleType(ScalingUtils.ScaleType.CENTER_CROP);
            break;
        case CENTER_INSIDE:
            hierarchy.setActualImageScaleType(ScalingUtils.ScaleType.CENTER_INSIDE);
            break;
    }
}
 
Example 3
Source File: ImagePreFragment.java    From SprintNBA with Apache License 2.0 5 votes vote down vote up
private void initImage() {
    PipelineDraweeControllerBuilder controller = FrescoUtils.getPreController(url, pdvImage);
    controller.setControllerListener(listener);
    final GenericDraweeHierarchy hierarchy = new GenericDraweeHierarchyBuilder(getResources())
            .setProgressBarImage(new ImageLoadProgressBar(new ImageLoadProgressBar.OnLevelChangeListener() {
                @Override
                public void onChange(int level) {
                    if (level >= 100) {
                        hideLoadingDialog();
                    }
                }
            }, Color.parseColor("#90CCCCCC"))).build();
    hierarchy.setActualImageScaleType(ScalingUtils.ScaleType.FIT_CENTER);
    pdvImage.setHierarchy(hierarchy);
    pdvImage.setController(controller.build());
    pdvImage.setOnPhotoTapListener(new OnPhotoTapListener() {
        @Override
        public void onPhotoTap(View view, float x, float y) {
            if (mActivity != null)
                mActivity.finish();
        }
    });
    pdvImage.setOnLongClickListener(new View.OnLongClickListener() {
        @Override
        public boolean onLongClick(View v) {

            return true;
        }
    });
}
 
Example 4
Source File: ImageFragment.java    From TLint with Apache License 2.0 5 votes vote down vote up
@Override
public void initData() {
    showContent(true);
    ImageRequest request = ImageRequestBuilder.newBuilderWithSource(Uri.parse(url))
            .setProgressiveRenderingEnabled(true)
            .build();

    GenericDraweeHierarchy hierarchy =
            new GenericDraweeHierarchyBuilder(getResources()).setProgressBarImage(
                    new ImageLoadProgressBar(new ImageLoadProgressBar.OnLevelChangeListener() {
                        @Override
                        public void onChange(int level) {
                            if (level > 100 && progress.getVisibility() == View.VISIBLE) {
                                progress.setVisibility(View.GONE);
                            }
                        }
                    }, ResourceUtil.getThemeColor(getActivity()))).build();
    hierarchy.setActualImageScaleType(ScalingUtils.ScaleType.FIT_CENTER);

    PipelineDraweeControllerBuilder controller = Fresco.newDraweeControllerBuilder();
    controller.setControllerListener(listener);
    controller.setImageRequest(request);
    controller.setOldController(image.getController());
    controller.setAutoPlayAnimations(true);
    image.setHierarchy(hierarchy);
    image.setController(controller.build());
}
 
Example 5
Source File: DraweeRoundedCornersFragment.java    From fresco with MIT License 5 votes vote down vote up
private void changeDraweeViewScaleType(
    SimpleDraweeView draweeView, ScaleType scaleType, @Nullable PointF focusPoint) {
  final GenericDraweeHierarchy hierarchy = draweeView.getHierarchy();
  hierarchy.setActualImageScaleType(scaleType);
  hierarchy.setActualImageFocusPoint(focusPoint != null ? focusPoint : new PointF(0.5f, 0.5f));

  final RoundingParams roundingParams = Preconditions.checkNotNull(hierarchy.getRoundingParams());
  if (BITMAP_ONLY_SCALETYPES.contains(scaleType)) {
    roundingParams.setRoundingMethod(RoundingParams.RoundingMethod.BITMAP_ONLY);
  } else {
    roundingParams.setOverlayColor(mWindowBackgroundColor);
  }
  hierarchy.setRoundingParams(roundingParams);
}
 
Example 6
Source File: FrescoImageHierarchyTools.java    From litho with Apache License 2.0 4 votes vote down vote up
public static void setupHierarchy(
    @Prop(optional = true) ScalingUtils.ScaleType actualImageScaleType,
    @Prop(optional = true) PointF actualImageFocusPoint,
    @Prop(optional = true) int fadeDuration,
    @Prop(optional = true, resType = DRAWABLE) Drawable failureImage,
    @Prop(optional = true) ScalingUtils.ScaleType failureImageScaleType,
    @Prop(optional = true, resType = DRAWABLE) Drawable placeholderImage,
    @Prop(optional = true) PointF placeholderImageFocusPoint,
    @Prop(optional = true) ScalingUtils.ScaleType placeholderImageScaleType,
    @Prop(optional = true, resType = DRAWABLE) Drawable progressBarImage,
    @Prop(optional = true) ScalingUtils.ScaleType progressBarImageScaleType,
    @Prop(optional = true, resType = DRAWABLE) Drawable retryImage,
    @Prop(optional = true) ScalingUtils.ScaleType retryImageScaleType,
    @Prop(optional = true) RoundingParams roundingParams,
    @Prop(optional = true) ColorFilter colorFilter,
    GenericDraweeHierarchy draweeHierarchy) {

  if (placeholderImage == null) {
    draweeHierarchy.setPlaceholderImage(null);
  } else {
    draweeHierarchy.setPlaceholderImage(placeholderImage, placeholderImageScaleType);
  }

  if (placeholderImageScaleType == ScalingUtils.ScaleType.FOCUS_CROP) {
    draweeHierarchy.setPlaceholderImageFocusPoint(placeholderImageFocusPoint);
  }

  draweeHierarchy.setActualImageScaleType(actualImageScaleType);
  if (actualImageFocusPoint != null
      && actualImageScaleType == ScalingUtils.ScaleType.FOCUS_CROP) {
    draweeHierarchy.setActualImageFocusPoint(actualImageFocusPoint);
  }
  draweeHierarchy.setFadeDuration(fadeDuration);

  if (failureImage == null) {
    draweeHierarchy.setFailureImage(null);
  } else {
    draweeHierarchy.setFailureImage(failureImage, failureImageScaleType);
  }

  if (progressBarImage == null) {
    draweeHierarchy.setProgressBarImage(null);
  } else {
    draweeHierarchy.setProgressBarImage(progressBarImage, progressBarImageScaleType);
  }

  if (retryImage == null) {
    draweeHierarchy.setRetryImage(null);
  } else {
    draweeHierarchy.setRetryImage(retryImage, retryImageScaleType);
  }

  draweeHierarchy.setRoundingParams(roundingParams);
  draweeHierarchy.setActualImageColorFilter(colorFilter);
}
 
Example 7
Source File: DraweeScaleTypeFragment.java    From fresco with MIT License 4 votes vote down vote up
private void changeMainDraweeScaleType(ScaleType scaleType, @Nullable PointF focusPoint) {
  final GenericDraweeHierarchy hierarchy = mDraweeMain.getHierarchy();
  hierarchy.setActualImageScaleType(scaleType);
  hierarchy.setActualImageFocusPoint(focusPoint != null ? focusPoint : new PointF(0.5f, 0.5f));
}