Search in sources :

Example 11 with GenericDraweeHierarchy

use of com.facebook.drawee.generic.GenericDraweeHierarchy in project fresco by facebook.

the class DraweeRoundedCornersFragment method changeDraweeViewScaleType.

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);
}
Also used : GenericDraweeHierarchy(com.facebook.drawee.generic.GenericDraweeHierarchy) PointF(android.graphics.PointF) RoundingParams(com.facebook.drawee.generic.RoundingParams)

Example 12 with GenericDraweeHierarchy

use of com.facebook.drawee.generic.GenericDraweeHierarchy in project fresco by facebook.

the class DraweeScaleTypeFragment method changeMainDraweeScaleType.

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));
}
Also used : GenericDraweeHierarchy(com.facebook.drawee.generic.GenericDraweeHierarchy) PointF(android.graphics.PointF)

Example 13 with GenericDraweeHierarchy

use of com.facebook.drawee.generic.GenericDraweeHierarchy in project GalleryFinal by pengjianbo.

the class FrescoImageLoader method displayImage.

@Override
public void displayImage(Activity activity, String path, final GFImageView imageView, final Drawable defaultDrawable, int width, int height) {
    Resources resources = context.getResources();
    GenericDraweeHierarchy hierarchy = new GenericDraweeHierarchyBuilder(resources).setFadeDuration(300).setPlaceholderImage(defaultDrawable).setFailureImage(defaultDrawable).setProgressBarImage(new ProgressBarDrawable()).build();
    final DraweeHolder<GenericDraweeHierarchy> draweeHolder = DraweeHolder.create(hierarchy, context);
    imageView.setOnImageViewListener(new GFImageView.OnImageViewListener() {

        @Override
        public void onDetach() {
            draweeHolder.onDetach();
        }

        @Override
        public void onAttach() {
            draweeHolder.onAttach();
        }

        @Override
        public boolean verifyDrawable(Drawable dr) {
            if (dr == draweeHolder.getHierarchy().getTopLevelDrawable()) {
                return true;
            }
            return false;
        }

        @Override
        public void onDraw(Canvas canvas) {
            Drawable drawable = draweeHolder.getHierarchy().getTopLevelDrawable();
            if (drawable == null) {
                imageView.setImageDrawable(defaultDrawable);
            } else {
                imageView.setImageDrawable(drawable);
            }
        }
    });
    Uri uri = new Uri.Builder().scheme(UriUtil.LOCAL_FILE_SCHEME).path(path).build();
    ImageRequest imageRequest = ImageRequestBuilder.newBuilderWithSource(uri).setResizeOptions(//图片目标大小
    new ResizeOptions(width, height)).build();
    DraweeController controller = Fresco.newDraweeControllerBuilder().setOldController(draweeHolder.getController()).setImageRequest(imageRequest).build();
    draweeHolder.setController(controller);
}
Also used : ProgressBarDrawable(com.facebook.drawee.drawable.ProgressBarDrawable) GenericDraweeHierarchy(com.facebook.drawee.generic.GenericDraweeHierarchy) GenericDraweeHierarchyBuilder(com.facebook.drawee.generic.GenericDraweeHierarchyBuilder) DraweeController(com.facebook.drawee.interfaces.DraweeController) Canvas(android.graphics.Canvas) Drawable(android.graphics.drawable.Drawable) ProgressBarDrawable(com.facebook.drawee.drawable.ProgressBarDrawable) Uri(android.net.Uri) ResizeOptions(com.facebook.imagepipeline.common.ResizeOptions) ImageRequest(com.facebook.imagepipeline.request.ImageRequest) Resources(android.content.res.Resources) GFImageView(cn.finalteam.galleryfinal.widget.GFImageView)

Example 14 with GenericDraweeHierarchy

use of com.facebook.drawee.generic.GenericDraweeHierarchy in project actor-platform by actorapp.

the class DialogView method initStyles.

protected void initStyles() {
    GenericDraweeHierarchy hierarchy = new GenericDraweeHierarchyBuilder(getResources()).setFadeDuration(0).setRoundingParams(new RoundingParams().setRoundAsCircle(true)).build();
    draweeHolder = DraweeHolder.create(hierarchy, getContext());
    draweeHolder.getTopLevelDrawable().setCallback(this);
    setLayoutParams(new RecyclerView.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, Screen.dp(72)));
    setDividerPaddingLeft(Screen.dp(72));
//        setLayerType(LAYER_TYPE_HARDWARE, null);
}
Also used : GenericDraweeHierarchy(com.facebook.drawee.generic.GenericDraweeHierarchy) GenericDraweeHierarchyBuilder(com.facebook.drawee.generic.GenericDraweeHierarchyBuilder) RecyclerView(android.support.v7.widget.RecyclerView) RoundingParams(com.facebook.drawee.generic.RoundingParams)

Example 15 with GenericDraweeHierarchy

use of com.facebook.drawee.generic.GenericDraweeHierarchy in project actor-platform by actorapp.

the class BackgroundPreviewView method init.

public void init(int width, int height, int corenerRadius) {
    this.width = width;
    this.height = height;
    GenericDraweeHierarchyBuilder builder = new GenericDraweeHierarchyBuilder(getResources());
    GenericDraweeHierarchy hierarchy = builder.setFadeDuration(200).setRoundingParams(new RoundingParams().setCornersRadius(corenerRadius).setRoundingMethod(RoundingParams.RoundingMethod.BITMAP_ONLY)).build();
    setHierarchy(hierarchy);
}
Also used : GenericDraweeHierarchyBuilder(com.facebook.drawee.generic.GenericDraweeHierarchyBuilder) GenericDraweeHierarchy(com.facebook.drawee.generic.GenericDraweeHierarchy) RoundingParams(com.facebook.drawee.generic.RoundingParams)

Aggregations

GenericDraweeHierarchy (com.facebook.drawee.generic.GenericDraweeHierarchy)20 GenericDraweeHierarchyBuilder (com.facebook.drawee.generic.GenericDraweeHierarchyBuilder)11 RoundingParams (com.facebook.drawee.generic.RoundingParams)5 ProgressBarDrawable (com.facebook.drawee.drawable.ProgressBarDrawable)4 DraweeController (com.facebook.drawee.interfaces.DraweeController)4 Uri (android.net.Uri)3 ResizeOptions (com.facebook.imagepipeline.common.ResizeOptions)3 ImageRequest (com.facebook.imagepipeline.request.ImageRequest)3 Canvas (android.graphics.Canvas)2 PointF (android.graphics.PointF)2 Drawable (android.graphics.drawable.Drawable)2 InstrumentedDraweeView (com.facebook.samples.comparison.instrumentation.InstrumentedDraweeView)2 InstrumentedDraweeView (com.facebook.samples.scrollperf.instrumentation.InstrumentedDraweeView)2 Context (android.content.Context)1 Resources (android.content.res.Resources)1 Animatable (android.graphics.drawable.Animatable)1 Nullable (android.support.annotation.Nullable)1 RecyclerView (android.support.v7.widget.RecyclerView)1 View (android.view.View)1 ViewGroup (android.view.ViewGroup)1