Search in sources :

Example 6 with GenericDraweeHierarchyBuilder

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

the class FrescoAdapter method onCreateViewHolder.

@Override
public FrescoHolder onCreateViewHolder(ViewGroup parent, int viewType) {
    GenericDraweeHierarchy gdh = new GenericDraweeHierarchyBuilder(getContext().getResources()).setPlaceholderImage(Drawables.sPlaceholderDrawable).setFailureImage(Drawables.sErrorDrawable).setProgressBarImage(new ProgressBarDrawable()).setActualImageScaleType(ScalingUtils.ScaleType.FIT_CENTER).build();
    final InstrumentedDraweeView instrView = new InstrumentedDraweeView(getContext(), gdh);
    return new FrescoHolder(getContext(), parent, instrView, getPerfListener());
}
Also used : ProgressBarDrawable(com.facebook.drawee.drawable.ProgressBarDrawable) FrescoHolder(com.facebook.samples.comparison.holders.FrescoHolder) GenericDraweeHierarchy(com.facebook.drawee.generic.GenericDraweeHierarchy) GenericDraweeHierarchyBuilder(com.facebook.drawee.generic.GenericDraweeHierarchyBuilder) InstrumentedDraweeView(com.facebook.samples.comparison.instrumentation.InstrumentedDraweeView)

Example 7 with GenericDraweeHierarchyBuilder

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

the class VolleyDraweeAdapter method onCreateViewHolder.

@Override
public VolleyDraweeHolder onCreateViewHolder(ViewGroup parent, int viewType) {
    GenericDraweeHierarchy gdh = new GenericDraweeHierarchyBuilder(getContext().getResources()).setPlaceholderImage(Drawables.sPlaceholderDrawable).setFailureImage(Drawables.sErrorDrawable).build();
    InstrumentedDraweeView view = new InstrumentedDraweeView(getContext());
    view.setHierarchy(gdh);
    return new VolleyDraweeHolder(getContext(), parent, view, getPerfListener());
}
Also used : GenericDraweeHierarchy(com.facebook.drawee.generic.GenericDraweeHierarchy) GenericDraweeHierarchyBuilder(com.facebook.drawee.generic.GenericDraweeHierarchyBuilder) VolleyDraweeHolder(com.facebook.samples.comparison.holders.VolleyDraweeHolder) InstrumentedDraweeView(com.facebook.samples.comparison.instrumentation.InstrumentedDraweeView)

Example 8 with GenericDraweeHierarchyBuilder

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

the class DraweeUtil method createDraweeHierarchy.

/**
   * Creates the Hierarchy using the information into the Config
   *
   * @param context The Context
   * @param config  The Config object
   * @return The Hierarchy to use
   */
public static GenericDraweeHierarchy createDraweeHierarchy(final Context context, final Config config) {
    GenericDraweeHierarchyBuilder builder = new GenericDraweeHierarchyBuilder(context.getResources()).setFadeDuration(config.fadeDurationMs).setPlaceholderImage(Const.PLACEHOLDER).setFailureImage(Const.FAILURE).setActualImageScaleType(ScalingUtils.ScaleType.FIT_CENTER);
    applyScaleType(builder, config);
    if (config.useRoundedCorners || config.drawBorder) {
        final Resources res = context.getResources();
        final RoundingParams roundingParams = new RoundingParams();
        if (config.useRoundedCorners) {
            roundingParams.setRoundingMethod(RoundingParams.RoundingMethod.BITMAP_ONLY);
            roundingParams.setCornersRadius(res.getDimensionPixelSize(R.dimen.drawee_corner_radius));
            roundingParams.setRoundAsCircle(config.useRoundedAsCircle);
        }
        if (config.drawBorder) {
            //noinspection deprecation
            roundingParams.setBorderColor(res.getColor(R.color.colorPrimary));
            roundingParams.setBorderWidth(res.getDimensionPixelSize(R.dimen.drawee_border_width));
        }
        builder.setRoundingParams(roundingParams);
    }
    return builder.build();
}
Also used : GenericDraweeHierarchyBuilder(com.facebook.drawee.generic.GenericDraweeHierarchyBuilder) Resources(android.content.res.Resources) RoundingParams(com.facebook.drawee.generic.RoundingParams)

Example 9 with GenericDraweeHierarchyBuilder

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

the class DraweeMocks method mockGenericDraweeHierarchyBuilder.

/**
   * Creates a mock GenericDraweeHierarchyBuilder that builds a new DH instance each time.
   * @return mock GenericDraweeHierarchyBuilder
   */
public static GenericDraweeHierarchyBuilder mockGenericDraweeHierarchyBuilder() {
    GenericDraweeHierarchyBuilder builder = mock(GenericDraweeHierarchyBuilder.class, CALLS_REAL_METHODS);
    doAnswer(new Answer<Object>() {

        @Override
        public DraweeHierarchy answer(InvocationOnMock invocation) throws Throwable {
            return mockDraweeHierarchy();
        }
    }).when(builder).build();
    return builder;
}
Also used : GenericDraweeHierarchyBuilder(com.facebook.drawee.generic.GenericDraweeHierarchyBuilder) InvocationOnMock(org.mockito.invocation.InvocationOnMock) GenericDraweeHierarchy(com.facebook.drawee.generic.GenericDraweeHierarchy) DraweeHierarchy(com.facebook.drawee.interfaces.DraweeHierarchy)

Example 10 with GenericDraweeHierarchyBuilder

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

the class ZoomableDraweeView method inflateHierarchy.

protected void inflateHierarchy(Context context, @Nullable AttributeSet attrs) {
    Resources resources = context.getResources();
    GenericDraweeHierarchyBuilder builder = new GenericDraweeHierarchyBuilder(resources).setActualImageScaleType(ScalingUtils.ScaleType.FIT_CENTER);
    GenericDraweeHierarchyInflater.updateBuilder(builder, context, attrs);
    setAspectRatio(builder.getDesiredAspectRatio());
    setHierarchy(builder.build());
}
Also used : GenericDraweeHierarchyBuilder(com.facebook.drawee.generic.GenericDraweeHierarchyBuilder) Resources(android.content.res.Resources)

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