Search in sources :

Example 11 with RoundingParams

use of com.facebook.drawee.generic.RoundingParams 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) {
    FrescoSystrace.beginSection("DraweeUtil#createDraweeHierarchy");
    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);
    }
    GenericDraweeHierarchy result = builder.build();
    FrescoSystrace.endSection();
    return result;
}
Also used : GenericDraweeHierarchyBuilder(com.facebook.drawee.generic.GenericDraweeHierarchyBuilder) GenericDraweeHierarchy(com.facebook.drawee.generic.GenericDraweeHierarchy) Resources(android.content.res.Resources) RoundingParams(com.facebook.drawee.generic.RoundingParams)

Aggregations

RoundingParams (com.facebook.drawee.generic.RoundingParams)11 GenericDraweeHierarchy (com.facebook.drawee.generic.GenericDraweeHierarchy)7 View (android.view.View)5 SimpleDraweeView (com.facebook.drawee.view.SimpleDraweeView)5 GenericDraweeHierarchyBuilder (com.facebook.drawee.generic.GenericDraweeHierarchyBuilder)4 Resources (android.content.res.Resources)2 Animatable (android.graphics.drawable.Animatable)2 Uri (android.net.Uri)2 ViewGroup (android.view.ViewGroup)2 CompoundButton (android.widget.CompoundButton)2 BaseControllerListener (com.facebook.drawee.controller.BaseControllerListener)2 ControllerListener (com.facebook.drawee.controller.ControllerListener)2 DraweeController (com.facebook.drawee.interfaces.DraweeController)2 ApplicationInfo (android.content.pm.ApplicationInfo)1 PackageManager (android.content.pm.PackageManager)1 PointF (android.graphics.PointF)1 Drawable (android.graphics.drawable.Drawable)1 Bundle (android.os.Bundle)1 Handler (android.os.Handler)1 Nullable (android.support.annotation.Nullable)1