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());
}
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());
}
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();
}
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;
}
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());
}
Aggregations