Search in sources :

Example 11 with GenericDraweeHierarchyBuilder

use of com.facebook.drawee.generic.GenericDraweeHierarchyBuilder 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 12 with GenericDraweeHierarchyBuilder

use of com.facebook.drawee.generic.GenericDraweeHierarchyBuilder 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 13 with GenericDraweeHierarchyBuilder

use of com.facebook.drawee.generic.GenericDraweeHierarchyBuilder 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)

Example 14 with GenericDraweeHierarchyBuilder

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

the class AvatarView method init.

public void init(int size, float placeholderTextSize) {
    this.size = size;
    this.placeholderTextSize = placeholderTextSize;
    GenericDraweeHierarchyBuilder builder = new GenericDraweeHierarchyBuilder(getResources());
    GenericDraweeHierarchy hierarchy = builder.setFadeDuration(200).setRoundingParams(new RoundingParams().setRoundAsCircle(true).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)

Example 15 with GenericDraweeHierarchyBuilder

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

the class StickerView method init.

private void init() {
    builder = new GenericDraweeHierarchyBuilder(getResources());
    GenericDraweeHierarchy hierarchy = builder.setFadeDuration(200).setActualImageScaleType(ScalingUtils.ScaleType.FIT_CENTER).build();
    setHierarchy(hierarchy);
    fastThumbLoader = new FastThumbLoader(this);
}
Also used : GenericDraweeHierarchyBuilder(com.facebook.drawee.generic.GenericDraweeHierarchyBuilder) GenericDraweeHierarchy(com.facebook.drawee.generic.GenericDraweeHierarchy) FastThumbLoader(im.actor.sdk.controllers.conversation.view.FastThumbLoader)

Aggregations

GenericDraweeHierarchyBuilder (com.facebook.drawee.generic.GenericDraweeHierarchyBuilder)16 GenericDraweeHierarchy (com.facebook.drawee.generic.GenericDraweeHierarchy)12 RoundingParams (com.facebook.drawee.generic.RoundingParams)4 Resources (android.content.res.Resources)3 ProgressBarDrawable (com.facebook.drawee.drawable.ProgressBarDrawable)3 Canvas (android.graphics.Canvas)2 Drawable (android.graphics.drawable.Drawable)2 Uri (android.net.Uri)2 DraweeController (com.facebook.drawee.interfaces.DraweeController)2 ResizeOptions (com.facebook.imagepipeline.common.ResizeOptions)2 ImageRequest (com.facebook.imagepipeline.request.ImageRequest)2 InstrumentedDraweeView (com.facebook.samples.comparison.instrumentation.InstrumentedDraweeView)2 InvocationOnMock (org.mockito.invocation.InvocationOnMock)2 ColorDrawable (android.graphics.drawable.ColorDrawable)1 RecyclerView (android.support.v7.widget.RecyclerView)1 GFImageView (cn.finalteam.galleryfinal.widget.GFImageView)1 DraweeHierarchy (com.facebook.drawee.interfaces.DraweeHierarchy)1 FrescoHolder (com.facebook.samples.comparison.holders.FrescoHolder)1 VolleyDraweeHolder (com.facebook.samples.comparison.holders.VolleyDraweeHolder)1 GalleryImageView (com.yancy.gallerypick.widget.GalleryImageView)1