Java 类com.facebook.drawee.generic.GenericDraweeHierarchyBuilder 实例源码

项目:GitHub    文件:DraweeMocksTest.java   
@Test
public void testMockBuilderOfDrawableHierarchies() {
  GenericDraweeHierarchy gdh = DraweeMocks.mockDraweeHierarchy();
  GenericDraweeHierarchyBuilder builder =
      DraweeMocks.mockBuilderOf(gdh);
  assertEquals(gdh, builder.build());
  assertEquals(gdh, builder.build());
  assertEquals(gdh, builder.build());
  assertEquals(gdh, builder.build());
  assertEquals(gdh, builder.build());

  GenericDraweeHierarchy gdh1 = DraweeMocks.mockDraweeHierarchy();
  GenericDraweeHierarchy gdh2 = DraweeMocks.mockDraweeHierarchy();
  GenericDraweeHierarchy gdh3 = DraweeMocks.mockDraweeHierarchy();
  GenericDraweeHierarchyBuilder multiBuilder =
      DraweeMocks.mockBuilderOf(gdh1, gdh2, gdh3);
  assertEquals(gdh1, multiBuilder.build());
  assertEquals(gdh2, multiBuilder.build());
  assertEquals(gdh3, multiBuilder.build());
  assertEquals(gdh3, multiBuilder.build());
  assertEquals(gdh3, multiBuilder.build());
}
项目:Zoomable    文件:MainActivity.java   
private void displayImage(SimpleDraweeView draweeView, String url) {
    GenericDraweeHierarchy hierarchy = draweeView.getHierarchy();
    //设置占位图
    if (hierarchy == null) {
        hierarchy = GenericDraweeHierarchyBuilder.newInstance(getResources())
                .setPlaceholderImage(getResources().getDrawable(R.mipmap.ic_launcher)
                        , ScalingUtils.ScaleType.CENTER).build();
        draweeView.setHierarchy(hierarchy);
    } else {
        hierarchy.setPlaceholderImage(getResources().getDrawable(R.mipmap.ic_launcher)
                , ScalingUtils.ScaleType.CENTER);
    }

    //构建ImageRequestBuilder,传入请求Uri
    ImageRequestBuilder requestBuilder = ImageRequestBuilder.newBuilderWithSource(Uri.parse(url));
    //构建Controller
    DraweeController controller = Fresco.newDraweeControllerBuilder()
            .setOldController(draweeView.getController())
            .setImageRequest(requestBuilder.build())
            .build();
    //设置图片,Fresco设置显示图片都是通过Controller来实现
    draweeView.setController(controller);
}
项目:CommentGallery    文件:CommentImageGrid.java   
private ViewGroup generateImageLayout() {
    SquareDraweeView imageView = new SquareDraweeView(mContext);

    GenericDraweeHierarchyBuilder builder =
            new GenericDraweeHierarchyBuilder(mContext.getResources());
    GenericDraweeHierarchy hierarchy = builder
            .setFadeDuration(300).setActualImageScaleType(ScalingUtils.ScaleType.CENTER_CROP)
            .build();
    if (mPlaceholderImageResId > 0) {
        hierarchy.setPlaceholderImage(mPlaceholderImageResId);
    }
    if (mFailureImageResId > 0) {
        hierarchy.setFailureImage(mFailureImageResId);
    }

    imageView.setHierarchy(hierarchy);
    RelativeLayout.LayoutParams imgLp = new RelativeLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT);
    imgLp.setMargins(mImageBorderThickness, mImageBorderThickness, mImageBorderThickness, mImageBorderThickness);
    RelativeLayout mainLayout = new RelativeLayout(mContext);
    mainLayout.setBackgroundColor(mImageBorderColor);
    mainLayout.addView(imageView, imgLp);
    return mainLayout;
}
项目:tumbviewer    文件:PhotoPostVH.java   
private SimpleDraweeView createSimpleDraweeView() {
    SimpleDraweeView view = new SimpleDraweeView(itemView.getContext());
    GenericDraweeHierarchyBuilder builder =
            new GenericDraweeHierarchyBuilder(itemView.getContext().getResources());
    GenericDraweeHierarchy hierarchy = builder
            .setActualImageScaleType(ScalingUtils.ScaleType.CENTER_CROP)
            .setPlaceholderImage(R.color.loading_color)
            .setPlaceholderImageScaleType(ScalingUtils.ScaleType.FIT_CENTER)
            .setFailureImage(R.mipmap.ic_failed)
            .setFailureImageScaleType(ScalingUtils.ScaleType.CENTER)
            .build();
    view.setHierarchy(hierarchy);
    view.setTag(atomicInteger.getAndIncrement());
    view.setOnClickListener(this);
    return view;
}
项目:react-native-udesk    文件:UdeskUtil.java   
public static void loadHeadView(Context context, SimpleDraweeView simpleDraweeView, Uri httpUri) {
    //初始化圆角圆形参数对象
    RoundingParams rp = new RoundingParams();
    //设置图像是否为圆形
    rp.setRoundAsCircle(true);

    final GenericDraweeHierarchy hierarchy = new GenericDraweeHierarchyBuilder(context.getResources())
            .setRoundingParams(rp)
            .build();

    DraweeController controller = Fresco.newDraweeControllerBuilder()
            .setUri(httpUri)
            .setTapToRetryEnabled(true)
            .setOldController(simpleDraweeView.getController())
            .build();
    simpleDraweeView.setHierarchy(hierarchy);
    simpleDraweeView.setController(controller);
}
项目:RNLearn_Project1    文件:FrescoBasedReactTextInlineImageSpan.java   
public FrescoBasedReactTextInlineImageSpan(
    Resources resources,
    int height,
    int width,
    @Nullable Uri uri,
    ReadableMap headers,
    AbstractDraweeControllerBuilder draweeControllerBuilder,
    @Nullable Object callerContext) {
  mDraweeHolder = new DraweeHolder(
      GenericDraweeHierarchyBuilder.newInstance(resources)
          .build()
  );
  mDraweeControllerBuilder = draweeControllerBuilder;
  mCallerContext = callerContext;

  mHeight = height;
  mWidth = width;
  mUri = (uri != null) ? uri : Uri.EMPTY;
  mHeaders = headers;
}
项目:RNLearn_Project1    文件:FrescoBasedReactTextInlineImageSpan.java   
public FrescoBasedReactTextInlineImageSpan(
    Resources resources,
    int height,
    int width,
    @Nullable Uri uri,
    ReadableMap headers,
    AbstractDraweeControllerBuilder draweeControllerBuilder,
    @Nullable Object callerContext) {
  mDraweeHolder = new DraweeHolder(
      GenericDraweeHierarchyBuilder.newInstance(resources)
          .build()
  );
  mDraweeControllerBuilder = draweeControllerBuilder;
  mCallerContext = callerContext;

  mHeight = height;
  mWidth = width;
  mUri = (uri != null) ? uri : Uri.EMPTY;
  mHeaders = headers;
}
项目:ReactNativeSignatureExample    文件:FrescoBasedReactTextInlineImageSpan.java   
public FrescoBasedReactTextInlineImageSpan(
    Resources resources,
    int height,
    int width,
    @Nullable Uri uri,
    AbstractDraweeControllerBuilder draweeControllerBuilder,
    @Nullable Object callerContext) {
  mDraweeHolder = new DraweeHolder(
      GenericDraweeHierarchyBuilder.newInstance(resources)
          .build()
  );
  mDraweeControllerBuilder = draweeControllerBuilder;
  mCallerContext = callerContext;

  mHeight = height;
  mWidth = width;
  mUri = (uri != null) ? uri : Uri.EMPTY;
}
项目:react-native-ibeacon-android    文件:FrescoBasedReactTextInlineImageSpan.java   
public FrescoBasedReactTextInlineImageSpan(
    Resources resources,
    int height,
    int width,
    @Nullable Uri uri,
    AbstractDraweeControllerBuilder draweeControllerBuilder,
    @Nullable Object callerContext) {
  mDraweeHolder = new DraweeHolder(
      GenericDraweeHierarchyBuilder.newInstance(resources)
          .build()
  );
  mDraweeControllerBuilder = draweeControllerBuilder;
  mCallerContext = callerContext;

  mHeight = height;
  mWidth = width;
  mUri = (uri != null) ? uri : Uri.EMPTY;
}
项目:Li-MVPArms    文件:PhotoView.java   
protected void init() {
    if (null == mAttacher || null == mAttacher.getImageView()) {
        mAttacher = new PhotoViewAttacher(this);
    }

    if (null != mPendingScaleType) {
        setScaleType(mPendingScaleType);
        mPendingScaleType = null;
    }

    if (mDraweeHolder == null) {
        GenericDraweeHierarchy hierarchy = new GenericDraweeHierarchyBuilder(getResources())
                .setFadeDuration(500)
                .setProgressBarImage(new CustomProgressbarDrawable(this))
                .build();
        mDraweeHolder = DraweeHolder.create(hierarchy, getContext());
    }
}
项目:Li-MVPArms    文件:ConfigConstants.java   
public static GenericDraweeHierarchy getGenericDraweeHierarchy(Context context){
      GenericDraweeHierarchy gdh = new GenericDraweeHierarchyBuilder(context.getResources())
//            .reset()//重置
//            .setActualImageColorFilter(colorFilter)//颜色过滤
//            .setActualImageFocusPoint(focusPoint)//focusCrop, 需要指定一个居中点
//            .setActualImageMatrix(actualImageMatrix)
//            .setActualImageScaleType(actualImageScaleType)//fresco:actualImageScaleType="focusCrop"缩放类型
//            .setBackground(background)//fresco:backgroundImage="@color/blue"背景图片
//            .setBackgrounds(backgrounds)
//            .setFadeDuration(fadeDuration)//fresco:fadeDuration="300"加载图片动画时间
              .setFailureImage(ConfigConstants.sErrorDrawable)//fresco:failureImage="@drawable/error"失败图
//            .setFailureImage(failureDrawable, failureImageScaleType)//fresco:failureImageScaleType="centerInside"失败图缩放类型
//            .setOverlay(overlay)//fresco:overlayImage="@drawable/watermark"叠加图
//            .setOverlays(overlays)
              .setPlaceholderImage(ConfigConstants.sPlaceholderDrawable)//fresco:placeholderImage="@color/wait_color"占位图
//            .setPlaceholderImage(placeholderDrawable, placeholderImageScaleType)//fresco:placeholderImageScaleType="fitCenter"占位图缩放类型
//            .setPressedStateOverlay(drawable)//fresco:pressedStateOverlayImage="@color/red"按压状态下的叠加图
              .setProgressBarImage(new ProgressBarDrawable())//进度条fresco:progressBarImage="@drawable/progress_bar"进度条
//            .setProgressBarImage(progressBarImage, progressBarImageScaleType)//fresco:progressBarImageScaleType="centerInside"进度条类型
//            .setRetryImage(retryDrawable)//fresco:retryImage="@drawable/retrying"点击重新加载
//            .setRetryImage(retryDrawable, retryImageScaleType)//fresco:retryImageScaleType="centerCrop"点击重新加载缩放类型
              .setRoundingParams(RoundingParams.asCircle())//圆形/圆角fresco:roundAsCircle="true"圆形
              .build();
      return gdh;
  }
项目:react-native-box-loaders    文件:FrescoBasedReactTextInlineImageSpan.java   
public FrescoBasedReactTextInlineImageSpan(
    Resources resources,
    int height,
    int width,
    @Nullable Uri uri,
    AbstractDraweeControllerBuilder draweeControllerBuilder,
    @Nullable Object callerContext) {
  mDraweeHolder = new DraweeHolder(
      GenericDraweeHierarchyBuilder.newInstance(resources)
          .build()
  );
  mDraweeControllerBuilder = draweeControllerBuilder;
  mCallerContext = callerContext;

  mHeight = height;
  mWidth = width;
  mUri = (uri != null) ? uri : Uri.EMPTY;
}
项目:Ironman    文件:FrescoBasedReactTextInlineImageSpan.java   
public FrescoBasedReactTextInlineImageSpan(
    Resources resources,
    int height,
    int width,
    @Nullable Uri uri,
    AbstractDraweeControllerBuilder draweeControllerBuilder,
    @Nullable Object callerContext) {
  mDraweeHolder = new DraweeHolder(
      GenericDraweeHierarchyBuilder.newInstance(resources)
          .build()
  );
  mDraweeControllerBuilder = draweeControllerBuilder;
  mCallerContext = callerContext;

  mHeight = height;
  mWidth = width;
  mUri = (uri != null) ? uri : Uri.EMPTY;
}
项目:Chateau    文件:FullScreenImageActivity.java   
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_view_image);

    final SimpleDraweeView mImageView = (SimpleDraweeView) findViewById(R.id.view_image_image);
    final int shortAnimTime = getResources().getInteger(android.R.integer.config_shortAnimTime);
    final GenericDraweeHierarchy hierarchy = new GenericDraweeHierarchyBuilder(getResources())
        .setFadeDuration(shortAnimTime)
        .setProgressBarImage(new ImageLoadingDrawable(getResources()))
        .setFailureImage(getResources().getDrawable(R.drawable.ic_upload_failed), ScalingUtils.ScaleType.CENTER_INSIDE)
        .setActualImageScaleType(ScalingUtils.ScaleType.FIT_CENTER)
        .build();
    mImageView.setHierarchy(hierarchy);

    mImageView.setImageURI(getIntent().getParcelableExtra(EXTRA_IMAGE_URI));
}
项目:ZoomableDraweeView-sample    文件:ViewPagerActivity.java   
@Override
public Object instantiateItem(ViewGroup container, int position) {
    ZoomableDraweeView view = new ZoomableDraweeView(container.getContext());
    view.setController(
            Fresco.newDraweeControllerBuilder()
                    .setUri(Uri.parse(items[position]))
                    .build());

    GenericDraweeHierarchy hierarchy =
            new GenericDraweeHierarchyBuilder(container.getResources())
                    .setActualImageScaleType(ScalingUtils.ScaleType.FIT_CENTER)
                    .setProgressBarImage(new ProgressBarDrawable())
                    .build();

    view.setHierarchy(hierarchy);

    container.addView(view,
            ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT);

    return view;
}
项目:ListItemFold    文件:ItemDataAdapter.java   
@Override
public View getView(int position, View convertView, ViewGroup parent) {
    if (convertView == null) {
        convertView = layoutInflater.inflate(R.layout.item_data, null);
        ViewHolder viewHolder = new ViewHolder();
        viewHolder.myImageView = (SimpleDraweeView) convertView.findViewById(R.id.my_image_view);
        viewHolder.myTitle = (TextView) convertView.findViewById(R.id.my_title);
        viewHolder.myContent = (TextView) convertView.findViewById(R.id.my_content);
        GenericDraweeHierarchyBuilder builder =
                new GenericDraweeHierarchyBuilder(context.getResources());
        GenericDraweeHierarchy hierarchy = builder
                .setFadeDuration(200)
                .setPlaceholderImage(new ColorDrawable(0xf2f2f2))
                .setProgressBarImage(new CircularProgressDrawable())
                .build();
        viewHolder.myImageView.setHierarchy(hierarchy);
        convertView.setTag(viewHolder);
    }
    initializeViews(getItem(position), (ViewHolder) convertView.getTag());
    return convertView;
}
项目:actor-platform    文件:CoverAvatarView.java   
private void init() {

        if (isInEditMode()) {
            return;
        }

        GenericDraweeHierarchyBuilder builder = new GenericDraweeHierarchyBuilder(getResources());

        builder.setActualImageScaleType(ScalingUtils.ScaleType.CENTER_CROP);
        builder.setOverlay(new CoverOverlayDrawable(getContext()));

        if (ActorSDK.sharedActor().style.getAvatarBackgroundResourse() != 0) {
            builder.setPlaceholderImage(getResources()
                    .getDrawable(ActorSDK.sharedActor().style.getAvatarBackgroundResourse()), ScalingUtils.ScaleType.CENTER_CROP);
        } else {
            builder.setPlaceholderImage(new ColorDrawable(
                    ActorSDK.sharedActor().style.getAvatarBackgroundColor()));
        }

        builder.setFadeDuration(0);

        setHierarchy(builder.build());
    }
项目:actor-platform    文件:CallBackgroundAvatarView.java   
public void init() {
    if(blurActor==null){
        blurActor = system().actorOf(Props.create(new ActorCreator() {
            @Override
            public BlurActor create() {
                return new BlurActor();
            }
        }), "actor/call_blur");
    }
    GenericDraweeHierarchyBuilder builder =
            new GenericDraweeHierarchyBuilder(getResources());

    GenericDraweeHierarchy hierarchy = builder
            .setFadeDuration(200)
            .build();
    setHierarchy(hierarchy);
}
项目:actor-platform    文件:AvatarView.java   
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))
            //.setActualImageColorFilter(new PorterDuffColorFilter(0x19000000, PorterDuff.Mode.MULTIPLY))
            //.setOverlay(new AvatarBorderDrawable())
            .build();
    setHierarchy(hierarchy);
}
项目:HaoCommon    文件:GifDemoActivity.java   
@Override
protected void initViewsAndEvents() {

    GenericDraweeHierarchyBuilder builder =
            new GenericDraweeHierarchyBuilder(getResources());
    GenericDraweeHierarchy hierarchy = builder
            .setFadeDuration(300)
            .setProgressBarImage(new CustomProgressbarDrawable(this))
            .build();
    DraweeController controller = Fresco.newDraweeControllerBuilder()
            .setUri(Uri.parse(url))
            .setAutoPlayAnimations(true)
            .build();
    gifview.setHierarchy(hierarchy);
    gifview.setController(controller);
}
项目:HaoCommon    文件:PhotoView.java   
protected void init() {
    if (null == mAttacher || null == mAttacher.getImageView()) {
        mAttacher = new PhotoViewAttacher(this);
    }

    if (null != mPendingScaleType) {
        setScaleType(mPendingScaleType);
        mPendingScaleType = null;
    }

    if (mDraweeHolder == null) {
        GenericDraweeHierarchy hierarchy = new GenericDraweeHierarchyBuilder(getResources())
                .setFadeDuration(300)
                .setProgressBarImage(new CustomProgressbarDrawable(this))
                .build();
        mDraweeHolder = DraweeHolder.create(hierarchy, getContext());
    }
}
项目:android-support-learn    文件:PApplication.java   
public static GenericDraweeHierarchy getGenericDraweeHierarchy(Context context){
        GenericDraweeHierarchy gdh = new GenericDraweeHierarchyBuilder(context.getResources())
//            .reset()//重置
//            .setActualImageColorFilter(colorFilter)//颜色过滤
//            .setActualImageFocusPoint(focusPoint)//focusCrop, 需要指定一个居中点
//            .setActualImageMatrix(actualImageMatrix)
//            .setActualImageScaleType(actualImageScaleType)//fresco:actualImageScaleType="focusCrop"缩放类型
//            .setBackground(background)//fresco:backgroundImage="@color/blue"背景图片
//            .setBackgrounds(backgrounds)
//            .setFadeDuration(fadeDuration)//fresco:fadeDuration="300"加载图片动画时间
         //       .setFailureImage(ConfigConstants.sErrorDrawable)//fresco:failureImage="@drawable/error"失败图
//            .setFailureImage(failureDrawable, failureImageScaleType)//fresco:failureImageScaleType="centerInside"失败图缩放类型
//            .setOverlay(overlay)//fresco:overlayImage="@drawable/watermark"叠加图
//            .setOverlays(overlays)
            //    .setPlaceholderImage(ConfigConstants.sPlaceholderDrawable)//fresco:placeholderImage="@color/wait_color"占位图
//            .setPlaceholderImage(placeholderDrawable, placeholderImageScaleType)//fresco:placeholderImageScaleType="fitCenter"占位图缩放类型
//            .setPressedStateOverlay(drawable)//fresco:pressedStateOverlayImage="@color/red"按压状态下的叠加图
                .setProgressBarImage(new ProgressBarDrawable())//进度条fresco:progressBarImage="@drawable/progress_bar"进度条
//            .setProgressBarImage(progressBarImage, progressBarImageScaleType)//fresco:progressBarImageScaleType="centerInside"进度条类型
//            .setRetryImage(retryDrawable)//fresco:retryImage="@drawable/retrying"点击重新加载
//            .setRetryImage(retryDrawable, retryImageScaleType)//fresco:retryImageScaleType="centerCrop"点击重新加载缩放类型
                .setRoundingParams(RoundingParams.asCircle())//圆形/圆角fresco:roundAsCircle="true"圆形
                .build();
        return gdh;
    }
项目:fresco    文件:DraweeMocksTest.java   
@Test
public void testMockBuilderOfDrawableHierarchies() {
  GenericDraweeHierarchy gdh = DraweeMocks.mockDraweeHierarchy();
  GenericDraweeHierarchyBuilder builder =
      DraweeMocks.mockBuilderOf(gdh);
  assertEquals(gdh, builder.build());
  assertEquals(gdh, builder.build());
  assertEquals(gdh, builder.build());
  assertEquals(gdh, builder.build());
  assertEquals(gdh, builder.build());

  GenericDraweeHierarchy gdh1 = DraweeMocks.mockDraweeHierarchy();
  GenericDraweeHierarchy gdh2 = DraweeMocks.mockDraweeHierarchy();
  GenericDraweeHierarchy gdh3 = DraweeMocks.mockDraweeHierarchy();
  GenericDraweeHierarchyBuilder multiBuilder =
      DraweeMocks.mockBuilderOf(gdh1, gdh2, gdh3);
  assertEquals(gdh1, multiBuilder.build());
  assertEquals(gdh2, multiBuilder.build());
  assertEquals(gdh3, multiBuilder.build());
  assertEquals(gdh3, multiBuilder.build());
  assertEquals(gdh3, multiBuilder.build());
}
项目:africhat-platform-0.1    文件:CoverAvatarView.java   
private void init() {

        if (isInEditMode()) {
            return;
        }

        GenericDraweeHierarchyBuilder builder =
                new GenericDraweeHierarchyBuilder(getResources());

        GenericDraweeHierarchy hierarchy = builder
                .setFadeDuration(160)
                .setActualImageScaleType(ScalingUtils.ScaleType.CENTER_CROP)
//                .setBackground(getResources().getDrawable(R.drawable.img_profile_avatar_default))
                .setOverlay(new CoverOverlayDrawable(getContext()))
                .build();
        setHierarchy(hierarchy);
    }
项目:africhat-platform-0.1    文件:AvatarView.java   
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))
                    // .setOverlay(new AvatarBorderDrawable())
            .build();
    setHierarchy(hierarchy);
}
项目:BlueBoard    文件:FrescoConfig.java   
public static GenericDraweeHierarchy getGenericDraweeHierarchy(Context context) {
        GenericDraweeHierarchy gdh = new GenericDraweeHierarchyBuilder(context.getResources())
//            .reset()//重置
//            .setActualImageColorFilter(colorFilter)//颜色过滤
//            .setActualImageFocusPoint(focusPoint)//focusCrop, 需要指定一个居中点
//            .setActualImageMatrix(actualImageMatrix)
//            .setActualImageScaleType(actualImageScaleType)//fresco:actualImageScaleType="focusCrop"缩放类型
//            .setBackground(background)//fresco:backgroundImage="@color/blue"背景图片
//            .setBackgrounds(backgrounds)
//            .setFadeDuration(fadeDuration)//fresco:fadeDuration="300"加载图片动画时间
                .setFailureImage(FrescoConfig.sErrorDrawable)//fresco:failureImage="@drawable/error"失败图
//            .setFailureImage(failureDrawable, failureImageScaleType)//fresco:failureImageScaleType="centerInside"失败图缩放类型
//            .setOverlay(overlay)//fresco:overlayImage="@drawable/watermark"叠加图
//            .setOverlays(overlays)
                .setPlaceholderImage(FrescoConfig.sPlaceholderDrawable)//fresco:placeholderImage="@color/wait_color"占位图
//            .setPlaceholderImage(placeholderDrawable, placeholderImageScaleType)//fresco:placeholderImageScaleType="fitCenter"占位图缩放类型
//            .setPressedStateOverlay(drawable)//fresco:pressedStateOverlayImage="@color/red"按压状态下的叠加图
                .setProgressBarImage(new ProgressBarDrawable())//进度条fresco:progressBarImage="@drawable/progress_bar"进度条
//            .setProgressBarImage(progressBarImage, progressBarImageScaleType)//fresco:progressBarImageScaleType="centerInside"进度条类型
//            .setRetryImage(retryDrawable)//fresco:retryImage="@drawable/retrying"点击重新加载
//            .setRetryImage(retryDrawable, retryImageScaleType)//fresco:retryImageScaleType="centerCrop"点击重新加载缩放类型
                .setRoundingParams(RoundingParams.asCircle())//圆形/圆角fresco:roundAsCircle="true"圆形
                .build();
        return gdh;
    }
项目:AndroidPlayground    文件:ShapedDraweeView.java   
private void setup(Context context, AttributeSet attrs, int defStyle) {
    if (getScaleType() == ScaleType.FIT_CENTER) {
        setScaleType(ScaleType.CENTER_CROP);
    }

    Drawable placeholder = null;
    if (attrs != null) {
        TypedArray typedArray =
                context.obtainStyledAttributes(attrs, R.styleable.ShapedDrawee, defStyle, 0);
        shape = typedArray.getDrawable(R.styleable.ShapedDrawee_maskShape);
        placeholder = typedArray.getDrawable(R.styleable.ShapedDrawee_placeholder);
        typedArray.recycle();
    }
    if (shape == null) {
        throw new IllegalArgumentException("maskShape must be specified in layout!");
    }

    GenericDraweeHierarchy hierarchy =
            new GenericDraweeHierarchyBuilder(getResources()).setPlaceholderImage(placeholder)
                    .setPlaceholderImageScaleType(ScalingUtils.ScaleType.CENTER_CROP)
                    .setActualImageScaleType(ScalingUtils.ScaleType.CENTER_CROP)
                    .build();
    mDraweeHolder = DraweeHolder.create(hierarchy, getContext());
}
项目:apps-android-wikipedia    文件:GalleryItemFragment.java   
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    View rootView = inflater.inflate(R.layout.fragment_gallery_item, container, false);
    progressBar = rootView.findViewById(R.id.gallery_item_progress_bar);
    videoContainer = rootView.findViewById(R.id.gallery_video_container);
    videoView = rootView.findViewById(R.id.gallery_video);
    videoThumbnail = rootView.findViewById(R.id.gallery_video_thumbnail);
    videoPlayButton = rootView.findViewById(R.id.gallery_video_play_button);
    imageView = rootView.findViewById(R.id.gallery_image);
    imageView.setTapListener(new DoubleTapGestureListener(imageView) {
        @Override
        public boolean onSingleTapConfirmed(MotionEvent e) {
            parentActivity.toggleControls();
            return true;
        }
    });
    GenericDraweeHierarchy hierarchy = new GenericDraweeHierarchyBuilder(getResources())
            .setActualImageScaleType(ScalingUtils.ScaleType.FIT_CENTER)
            .build();
    imageView.setHierarchy(hierarchy);
    return rootView;
}
项目:GitHub    文件:DraweeMocks.java   
/**
 * 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;
}
项目:GitHub    文件:DraweeMocks.java   
/**
 * Creates a mock GenericDraweeHierarchyBuilder with stubbed build.
 * @param drawableHierarchies drawable hierarchies to return on {@code build()}
 * @return mock GenericDraweeHierarchyBuilder
 */
public static GenericDraweeHierarchyBuilder mockBuilderOf(
    GenericDraweeHierarchy... drawableHierarchies) {
  GenericDraweeHierarchyBuilder builder =
      mock(GenericDraweeHierarchyBuilder.class, CALLS_REAL_METHODS);
  final Supplier<GenericDraweeHierarchy> gdhProvider = supplierOf(drawableHierarchies);
  doAnswer(
      new Answer() {
        @Override
        public Object answer(InvocationOnMock invocation) throws Throwable {
          return gdhProvider.get();
        }
      }).when(builder).build();
  return builder;
}
项目:GitHub    文件:VolleyDraweeAdapter.java   
@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());
}
项目:GitHub    文件:FrescoAdapter.java   
@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());
}
项目:GitHub    文件:ZoomableDraweeView.java   
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());
}
项目:GitHub    文件:DraweeUtil.java   
/**
 * 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();
}
项目:GitHub    文件:DraweeUtil.java   
public static void applyScaleType(GenericDraweeHierarchyBuilder builder, final Config config) {
  switch (config.scaleType) {
    case "scale_type_none":
      builder.setActualImageScaleType(null);
      break;
    case "scale_type_center":
      builder.setActualImageScaleType(ScalingUtils.ScaleType.CENTER);
      break;
    case "scale_type_center_crop":
      builder.setActualImageScaleType(ScalingUtils.ScaleType.CENTER_CROP);
      break;
    case "scale_type_center_inside":
      builder.setActualImageScaleType(ScalingUtils.ScaleType.CENTER_INSIDE);
      break;
    case "scale_type_fit_center":
      builder.setActualImageScaleType(ScalingUtils.ScaleType.FIT_CENTER);
      break;
    case "scale_type_fit_start":
      builder.setActualImageScaleType(ScalingUtils.ScaleType.FIT_START);
      break;
    case "scale_type_fit_end":
      builder.setActualImageScaleType(ScalingUtils.ScaleType.FIT_END);
      break;
    case "scale_type_fit_xy":
      builder.setActualImageScaleType(ScalingUtils.ScaleType.FIT_XY);
      break;
  }
}
项目:Zoomable    文件:ZoomableDraweeView.java   
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());
}
项目:FrescoLoader    文件:FrescoLoader.java   
private FrescoLoader(Context context) {
    this.mContext = context.getApplicationContext();
    this.mDraweeHolderDispatcher = null;

    this.mDesiredAspectRatio = 0;
    this.mUseFixedWidth = true;
    this.mFadeDuration = GenericDraweeHierarchyBuilder.DEFAULT_FADE_DURATION;

    this.mPlaceholderDrawable = null;
    this.mPlaceholderScaleType = GenericDraweeHierarchyBuilder.DEFAULT_SCALE_TYPE;

    this.mRetryDrawable = null;
    this.mRetryScaleType = GenericDraweeHierarchyBuilder.DEFAULT_SCALE_TYPE;

    this.mFailureDrawable = null;
    this.mFailureScaleType = GenericDraweeHierarchyBuilder.DEFAULT_SCALE_TYPE;

    this.mProgressBarDrawable = null;
    this.mProgressScaleType = GenericDraweeHierarchyBuilder.DEFAULT_SCALE_TYPE;

    this.mActualImageScaleType = GenericDraweeHierarchyBuilder.DEFAULT_ACTUAL_IMAGE_SCALE_TYPE;
    this.mActualImageFocusPoint = null;
    this.mActualImageColorFilter = null;

    this.mBackgroundDrawable = null;
    this.mOverlays = null;
    this.mPressedStateOverlay = null;
    this.mRoundingParams = null;

    this.mTapToRetryEnabled = false;
    this.mAutoPlayAnimations = false;
    this.mRetainImageOnFailure = false;
    this.mProgressiveRenderingEnabled = false;
    this.mLocalThumbnailPreviewsEnabled = false;

    this.mPostprocessor = null;
    this.mControllerListener = null;
    this.mDraweeHolder = null;
}
项目:CommentGallery    文件:ZoomableDraweeView.java   
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());
}
项目:Watermark    文件:FrescoImageLoader.java   
private void init(Context ctx, Drawable defaultDrawable) {
    if (draweeHolder == null) {
        Resources resources = ctx.getResources();
        GenericDraweeHierarchy hierarchy = new GenericDraweeHierarchyBuilder(resources)
                .setPlaceholderImage(defaultDrawable)
                .setFailureImage(defaultDrawable)
                .build();
        draweeHolder = DraweeHolder.create(hierarchy, ctx);
    }
}
项目:GongXianSheng    文件:FrecoFactory.java   
public void setDefaultHierarchy(DraweeView draweeView, Drawable defaultDrawable, ScalingUtils.ScaleType defaultScaleType, ScalingUtils.ScaleType targerScaleType, boolean isCircle) {
        GenericDraweeHierarchy gdh = new GenericDraweeHierarchyBuilder( mContext.getResources())
                .setPlaceholderImage(defaultDrawable, defaultScaleType)
                .setFailureImage(defaultDrawable, ScalingUtils.ScaleType.CENTER_CROP)
//              .setProgressBarImage(new ProgressBarDrawable())
                .setActualImageScaleType(targerScaleType)
                .build();
        if ( isCircle ) {
            gdh.setRoundingParams(RoundingParams.asCircle());
        }
        draweeView.setHierarchy(gdh);
    }