Java 类com.facebook.drawee.backends.pipeline.PipelineDraweeControllerBuilder 实例源码

项目:GitHub    文件:DraweeViewHolder.java   
/**
 * @param uri The Uri to show into the DraweeView for this Holder
 */
public void bind(Uri uri) {
  mDraweeView.initInstrumentation(uri.toString(), mPerfListener);
  ImageRequestBuilder imageRequestBuilder = ImageRequestBuilder
      .newBuilderWithSource(uri)
      .setResizeOptions(
          new ResizeOptions(
            mDraweeView.getLayoutParams().width,
            mDraweeView.getLayoutParams().height));
  PipelineUtil.addOptionalFeatures(imageRequestBuilder, mConfig);
  // Create the Builder
  PipelineDraweeControllerBuilder builder = Fresco.newDraweeControllerBuilder()
                                                    .setImageRequest(imageRequestBuilder.build());
  if (mConfig.reuseOldController) {
    builder.setOldController(mDraweeView.getController());
  }
  mDraweeView.setListener(builder);
  mDraweeView.setController(builder.build());
}
项目:react-native-udesk    文件:UdeskUtil.java   
public static void loadImage(final PhotoDraweeView mPhotoDraweeView,
                             Uri uri) {
    PipelineDraweeControllerBuilder controller = Fresco.newDraweeControllerBuilder();
    controller.setUri(uri);
    controller.setAutoPlayAnimations(true);
    controller.setOldController(mPhotoDraweeView.getController());
    controller.setControllerListener(new BaseControllerListener<ImageInfo>() {
        @Override
        public void onFinalImageSet(String id, ImageInfo imageInfo, Animatable animatable) {
            super.onFinalImageSet(id, imageInfo, animatable);
            if (imageInfo == null || mPhotoDraweeView == null) {
                return;
            }
            mPhotoDraweeView.update(imageInfo.getWidth(), imageInfo.getHeight());
        }
    });
    mPhotoDraweeView.setController(controller.build());
}
项目:android-photo-picker    文件:PhotoDraweeView.java   
public void loadImage(String url,String lowurl, int placeHolderResId, int errorResId,ScalingUtils.ScaleType scaleType){
    final boolean isHttp = url.startsWith("http");
    Uri uri = isHttp ? Uri.parse(url) :  Uri.fromFile(new File(url));
    PipelineDraweeControllerBuilder controller = Fresco.newDraweeControllerBuilder()
         .setImageRequest(ImageRequest.fromUri(uri));
    if(lowurl!=null &&  lowurl.startsWith("http")) {
        controller .setLowResImageRequest(ImageRequest.fromUri(lowurl));
    }
    getHierarchy().setActualImageScaleType(scaleType);
                    // controller.setUri(URI);
    getHierarchy().setPlaceholderImage(getResources().getDrawable( placeHolderResId ),scaleType);
    getHierarchy().setFailureImage(getResources().getDrawable(errorResId),scaleType);
    controller.setOldController(this.getController())
         .setControllerListener(new BaseControllerListener<ImageInfo>() {
             @Override
             public void onFinalImageSet(String id, ImageInfo imageInfo, Animatable animatable) {
                 if (imageInfo == null) {
                     return;
                 }
                 PhotoDraweeView.this.update(imageInfo.getWidth(), imageInfo.getHeight());
             }
         });
    this.setController(controller.build());
}
项目:Li-MVPArms    文件:FrescoHelper.java   
/**
     * 图像选项类
     * @param uri 图片路径
     * @param oldController DraweeView.getoldcontroller
     * @param controllerListener 监听
     * @return
     */
    public static DraweeController getImageViewController(String uri, DraweeController oldController,
            ControllerListener<ImageInfo> controllerListener) {
        PipelineDraweeControllerBuilder builder = Fresco.newDraweeControllerBuilder();
        if (!TextUtils.isEmpty(uri)) {
//          Logger.d("StringUtils.utf8Encode(uri)"+StringUtils.utf8Encode(uri));
            builder.setUri(Uri.parse(uri));
        }
        if (oldController != null) {
            builder.setOldController(oldController);
        }
        if (controllerListener != null) {
            builder.setControllerListener(controllerListener);
        }
        return builder.build();
    }
项目:Elephant    文件:PhotoShowActivity.java   
@Override
public void initLoad() {
    super.initLoad();

    if (!TextUtils.isEmpty(mImageUrl)) {
        PipelineDraweeControllerBuilder controller = Fresco.newDraweeControllerBuilder();
        controller.setUri(mImageUrl);
        controller.setOldController(mPhotoIv.getController());
        controller.setControllerListener(new BaseControllerListener<ImageInfo>() {
            @Override
            public void onFinalImageSet(String id, ImageInfo imageInfo, Animatable animatable) {
                super.onFinalImageSet(id, imageInfo, animatable);
                if (imageInfo == null || mPhotoIv == null) {
                    return;
                }
                mPhotoIv.update(imageInfo.getWidth(), imageInfo.getHeight());
            }
        });
        mPhotoIv.setController(controller.build());
    }
}
项目:AndroidImageSelect    文件:PhotoDraweeViewUtil.java   
public static void display(final PhotoDraweeView draweeView, Uri uri) {
    PipelineDraweeControllerBuilder controller = Fresco.newDraweeControllerBuilder();
    controller.setUri(uri);
    controller.setOldController(draweeView.getController());
    controller.setControllerListener(new BaseControllerListener<ImageInfo>() {
        @Override
        public void onFinalImageSet(String id, ImageInfo imageInfo, Animatable animatable) {
            super.onFinalImageSet(id, imageInfo, animatable);
            if (imageInfo == null || draweeView == null) {
                return;
            }
            draweeView.update(imageInfo.getWidth(), imageInfo.getHeight());
        }
    });
    draweeView.setController(controller.build());
}
项目:phphub-android    文件:GalleryActivity.java   
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    String imageUrl = getIntent().getStringExtra(IMAGE_URL);
    if (!TextUtils.isEmpty(imageUrl)) {
        PipelineDraweeControllerBuilder builder = Fresco.newDraweeControllerBuilder();
        builder.setUri(Uri.parse(imageUrl));
        builder.setOldController(photoView.getController());
        builder.setControllerListener(new BaseControllerListener<ImageInfo>() {
            @Override
            public void onFinalImageSet(String id, ImageInfo imageInfo, Animatable animatable) {
                super.onFinalImageSet(id, imageInfo, animatable);
                if (imageInfo == null || photoView == null) {
                    return;
                }
                photoView.update(imageInfo.getWidth(), imageInfo.getHeight());
            }
        });
        photoView.setController(builder.build());
    }
}
项目:android-mg-bootstrap    文件:MGImages.java   
public static void setImage(ImageView view, String url, int width, int height) {

        // Create URI.
        Uri uri = Uri.parse(url);

        // Create an image controller builder.
        PipelineDraweeControllerBuilder builder = Fresco.newDraweeControllerBuilder();

        // Provide some standard config.
        builder = builder.setOldController(getDrawee(view).getController()).setUri(uri).setAutoPlayAnimations(true);

        // Get image request.
        ImageRequestBuilder request = getImageRequest(url, width, height);

        // Generate the final controller with image request.
        getDrawee(view).setController(builder.setImageRequest(request.build()).build());
    }
项目:fresco    文件:DraweeViewHolder.java   
/**
 * @param uri The Uri to show into the DraweeView for this Holder
 */
public void bind(Uri uri) {
  mDraweeView.initInstrumentation(uri.toString(), mPerfListener);
  ImageRequestBuilder imageRequestBuilder = ImageRequestBuilder
      .newBuilderWithSource(uri)
      .setResizeOptions(
          new ResizeOptions(
            mDraweeView.getLayoutParams().width,
            mDraweeView.getLayoutParams().height));
  PipelineUtil.addOptionalFeatures(imageRequestBuilder, mConfig);
  // Create the Builder
  PipelineDraweeControllerBuilder builder = Fresco.newDraweeControllerBuilder()
                                                    .setImageRequest(imageRequestBuilder.build());
  if (mConfig.reuseOldController) {
    builder.setOldController(mDraweeView.getController());
  }
  mDraweeView.setListener(builder);
  mDraweeView.setController(builder.build());
}
项目:S1-Go    文件:ImageLoader.java   
public void displayImage(String imageUri, ImageView imageView, ImageLoadingListener listener) {
    if (TextUtils.isEmpty(imageUri)) return;

    if (imageView instanceof GenericDraweeView) {
        if (listener != null) {
            PipelineDraweeControllerBuilder builder = Fresco.newDraweeControllerBuilder();
            ImageLoaderListener listener1 = new ImageLoaderListener();
            listener1.setData(listener, imageUri, imageView);
            ImageRequest request = ImageRequestBuilder.newBuilderWithSource(Uri.parse(imageUri)).build();
            AbstractDraweeController controller = builder.setOldController(((GenericDraweeView) imageView).getController()).setControllerListener(listener1).setImageRequest(request).build();
            ((GenericDraweeView) imageView).setController(controller);
            return;
        }
    }
    imageView.setImageURI(Uri.parse(imageUri));
}
项目:GitHub    文件:DraweeViewListAdapter.java   
@Override
public View getView(int position, View convertView, ViewGroup parent) {
  InstrumentedDraweeView draweeView;
  if (convertView == null) {
    final Context context = parent.getContext();
    GenericDraweeHierarchy gdh = DraweeUtil.createDraweeHierarchy(context, mConfig);
    draweeView = new InstrumentedDraweeView(context, gdh, mConfig);
    SizeUtil.setConfiguredSize(parent, draweeView, mConfig);
    draweeView.setPadding(mPaddingPx, mPaddingPx, mPaddingPx, mPaddingPx);
  } else {
    draweeView = (InstrumentedDraweeView) convertView;
  }
  final Uri uri = getItem(position);
  draweeView.initInstrumentation(uri.toString(), mPerfListener);
  ImageRequestBuilder imageRequestBuilder = ImageRequestBuilder
          .newBuilderWithSource(uri)
          .setResizeOptions(
                  new ResizeOptions(
                          draweeView.getLayoutParams().width,
                          draweeView.getLayoutParams().height));
  PipelineUtil.addOptionalFeatures(imageRequestBuilder, mConfig);
  // Create the Builder
  PipelineDraweeControllerBuilder builder = Fresco.newDraweeControllerBuilder()
          .setImageRequest(imageRequestBuilder.build());
  if (mConfig.reuseOldController) {
    builder.setOldController(draweeView.getController());
  }
  if (mConfig.instrumentationEnabled) {
    draweeView.setListener(builder);
  }
  draweeView.setController(builder.build());
  return draweeView;
}
项目:JD-Test    文件:GifImageView.java   
public void setImageUriAndAutoPlay(String uri){
    PipelineDraweeControllerBuilder builder = Fresco.newDraweeControllerBuilder()
            .setAutoPlayAnimations(true);
    if(!TextUtils.isEmpty(uri)){
        builder.setUri(Uri.parse(uri));
    }
    setController(builder.build());
}
项目:TakeRest    文件:PhotoViewActivity.java   
@Override
protected void init() {
    super.init();
    transparentStatusBar();
    ButterKnife.bind(this);
    url = getIntent().getStringExtra("url");
    PipelineDraweeControllerBuilder controller = Fresco.newDraweeControllerBuilder();
    controller.setUri(Uri.parse(url));
    controller.setAutoPlayAnimations(true);
    controller.setOldController(photoDraweeView.getController());
    controller.setControllerListener(new BaseControllerListener<ImageInfo>() {
        @Override
        public void onFinalImageSet(String id, ImageInfo imageInfo, Animatable animatable) {
            super.onFinalImageSet(id, imageInfo, animatable);
            if (imageInfo == null || photoDraweeView == null) {
                return;
            }
            photoDraweeView.update(imageInfo.getWidth(), imageInfo.getHeight());
            normalScale = photoDraweeView.getScale();
        }
    });
    photoDraweeView.setController(controller.build());
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP){
        String name = getIntent().getStringExtra("transition_name");
        photoDraweeView.setTransitionName(name);
        getWindow().setSharedElementEnterTransition(DraweeTransition.createTransitionSet(
                ScalingUtils.ScaleType.CENTER_CROP, ScalingUtils.ScaleType.FIT_CENTER));
        getWindow().setSharedElementReturnTransition(DraweeTransition.createTransitionSet(
                ScalingUtils.ScaleType.FIT_CENTER, ScalingUtils.ScaleType.CENTER_CROP));
    }
}
项目:TakeRest    文件:WrapContentDraweeView.java   
@Override
public void setImageURI(Uri uri, Object callerContext) {
    DraweeController controller = ((PipelineDraweeControllerBuilder)getControllerBuilder())
            .setControllerListener(listener)
            .setCallerContext(callerContext)
            .setUri(uri)
            .setOldController(getController())
            .build();
    setController(controller);
}
项目:android-photo-picker    文件:CommonDraweeView.java   
/***
 * load net work image.
 * @param url the main url of image, from net
 * @param lowUrl the low url, from net or local image file name, can be null.
 * @param placeHolder the place holder. 0 with no place holder
 * @param errorResId error res id , 0 with no error res.
 * @param width the width you want
 * @param height the height you want
 * @param scaleType scale type
 * @param l BaseControllerListener,can be null
 */
public void loadImage(String url, String lowUrl,int placeHolder, int errorResId,
                      ScalingUtils.ScaleType scaleType, int width , int height ,
                      final BaseControllerListener<ImageInfo> l){
    ImageRequest request = ImageRequestBuilder
            .newBuilderWithSource(Uri.parse(url))
            //.setLowestPermittedRequestLevel(ImageRequest.RequestLevel.FULL_FETCH)
            .setResizeOptions(new ResizeOptions(width, height))
            .build();
    getHierarchy().setActualImageScaleType(scaleType);
    if(placeHolder!=0) {
        getHierarchy().setPlaceholderImage(getResources().getDrawable( placeHolder ),scaleType);
    }
    if(errorResId!=0){
        getHierarchy().setFailureImage(getResources().getDrawable( errorResId ),scaleType);
    }
    PipelineDraweeControllerBuilder controller = Fresco.newDraweeControllerBuilder()
            .setControllerListener(l)
            .setImageRequest(request)
            .setOldController(getController());
    if(lowUrl!=null){
        Uri lowUri = lowUrl.startsWith("http") ? Uri.parse(lowUrl) : Uri.fromFile(new File(lowUrl));
        controller.setLowResImageRequest(ImageRequestBuilder.newBuilderWithSource(lowUri)
                .setResizeOptions(new ResizeOptions(width, height))
                .build() );
    }
    setController(controller.build());
}
项目:JianshuApp    文件:UniversalDraweeView.java   
private void loadImageURI(Uri uri, @Nullable Object callerContext, int width, int height) {
    // 对URL做格式转换、尺寸限制等处理
    uri = Uri.parse(ImageUtils.format(uri.toString(), DisplayInfo.getWidthPixels()));

    ImageRequestBuilder imageRequestBuilder = ImageRequestBuilder.newBuilderWithSource(uri);
    imageRequestBuilder.setProgressiveRenderingEnabled(true);

    imageRequestBuilder.setRotationOptions(RotationOptions.autoRotateAtRenderTime());
    if (width > 0 && height > 0) {
        imageRequestBuilder.setResizeOptions(new ResizeOptions(width, height));
    }

    PipelineDraweeControllerBuilder controller = Fresco.newDraweeControllerBuilder()
            .setCallerContext(callerContext)
            .setImageRequest(imageRequestBuilder.build())
            .setOldController(getController())
            .setAutoPlayAnimations(true)  // 自动播放动态图
            .setTapToRetryEnabled(true)  // 在加载失败时,可以点击重新加载
            .setControllerListener(new BaseControllerListener<ImageInfo>() {
                @Override
                public void onFinalImageSet(String id,
                                            ImageInfo imageInfo,
                                            Animatable animatable) {
                    super.onFinalImageSet(id, imageInfo, animatable);
                    onUpdateImage(imageInfo);
                }
            });
    if (AppUtils.isMainThread()) {
        setController(controller.build());
    } else {
        Observable.just(0)
                .observeOn(AndroidSchedulers.mainThread())
                .subscribe(it -> setController(controller.build()));
    }
}
项目:NApply    文件:FrescoImageLoader.java   
private PipelineDraweeControllerBuilder initControllerBuilder(){
    return Fresco.newDraweeControllerBuilder()
            .setAutoPlayAnimations(true)
            .setTapToRetryEnabled(true)
            .setRetainImageOnFailure(true)
            ;
}
项目:FrescoCustomCacheKey    文件:FrescoImageLoader.java   
/**
 * 获取DraweeController
 *
 * @param imageRequest 设置单个图片请求~~~不可与setFirstAvailableImageRequests共用,配合setLowResImageRequest为高分辨率的图
 * @param lowResImageRequest 先下载显示低分辨率的图
 * @param firstAvailableImageRequests 本地图片复用,可加入ImageRequest数组
 * @param controllerListener 监听图片下载完毕等
 * @param tapToRetryEnabled 点击重新加载图
 */
public static PipelineDraweeControllerBuilder getDraweeController(SimpleDraweeView view, @Nullable ImageRequest imageRequest, ImageRequest lowResImageRequest, @Nullable ImageRequest[] firstAvailableImageRequests, @Nullable ControllerListener<ImageInfo> controllerListener, boolean tapToRetryEnabled) {
    PipelineDraweeControllerBuilder builder = Fresco
            .newDraweeControllerBuilder();
    //自动播放图片动画
    builder.setAutoPlayAnimations(true);
    //点击重新加载图
    builder.setTapToRetryEnabled(tapToRetryEnabled);
    if (firstAvailableImageRequests != null &&
            firstAvailableImageRequests.length > 0) {
        //本地图片复用,可加入ImageRequest数组
        builder.setFirstAvailableImageRequests(firstAvailableImageRequests);
    } else if (imageRequest != null) {
        //设置单个图片请求~~~不可与setFirstAvailableImageRequests共用,配合setLowResImageRequest为高分辨率的图
        builder.setImageRequest(imageRequest);
        if (lowResImageRequest != null) {
            //先下载显示低分辨率的图
            builder.setLowResImageRequest(lowResImageRequest);
        }
    }
    if (controllerListener != null) {
        //监听图片下载完毕等
        builder.setControllerListener(controllerListener);
    }
    //DraweeController复用
    builder.setOldController(view.getController());
    return builder;
}
项目:Ghibli    文件:ImageUtil.java   
public static void loadImage(SimpleDraweeView simpleDraweeView, String url) {
  if (url == null) {
    return;
  }
  ImageRequest imageRequest = ImageRequestBuilder.newBuilderWithSource(Uri.parse(url))
      .setImageType(ImageRequest.ImageType.SMALL)
      .build();
  PipelineDraweeControllerBuilder pipelineDraweeControllerBuilder =
      Fresco.newDraweeControllerBuilder();
  pipelineDraweeControllerBuilder.setImageRequest(imageRequest);
  simpleDraweeView.setController(pipelineDraweeControllerBuilder
      .setOldController(simpleDraweeView.getController())
      .setAutoPlayAnimations(true)
      .build());
}
项目:H-Viewer    文件:ImageLoader.java   
public static RetainingDataSourceSupplier loadImageFromUrlRetainingImage(Context context, ImageView imageView, String url, String cookie, String referer, boolean noCache, ControllerListener controllerListener) {
    if (TextUtils.isEmpty(url)) {
        imageView.setImageURI(null);
        return null;
    }
    Uri uri = Uri.parse(url);
    JsonObject header = new JsonObject();
    header.addProperty("Cookie", cookie);
    header.addProperty("Referer", referer);
    if (url != null && url.startsWith("http")) {
        if (HProxy.isEnabled() && HProxy.isAllowPicture()) {
            HProxy proxy = new HProxy(url);
            header.addProperty(proxy.getHeaderKey(), proxy.getHeaderValue());
        }
        MyOkHttpNetworkFetcher.headers.put(uri, getGson().toJson(header));
    }
    if (imageView instanceof SimpleDraweeView) {
        SimpleDraweeView draweeView = ((SimpleDraweeView) imageView);
        RetainingDataSourceSupplier<CloseableReference<CloseableImage>> retainingSupplier = new RetainingDataSourceSupplier<>();
        PipelineDraweeControllerBuilder draweeControllerBuilder = Fresco.newDraweeControllerBuilder();
        draweeControllerBuilder.setDataSourceSupplier(retainingSupplier);
        DraweeController controller = draweeControllerBuilder
                .setCallerContext(context)
                .setTapToRetryEnabled(true)
                .setAutoPlayAnimations(true)
                .setOldController(draweeView.getController())
                .setControllerListener(controllerListener)
                .build();
        draweeView.setController(controller);
        ImageRequestBuilder requestBuilder = ImageRequestBuilder.newBuilderWithSource(uri)
                .setResizeOptions(new ResizeOptions(1080, 1920));
        if (noCache)
            requestBuilder.disableDiskCache();
        ImageRequest request = requestBuilder.build();
        retainingSupplier.setSupplier(Fresco.getImagePipeline().getDataSourceSupplier(request, null, ImageRequest.RequestLevel.FULL_FETCH));
        return retainingSupplier;
    }
    return null;
}
项目:SprintNBA    文件:FrescoUtils.java   
public static PipelineDraweeControllerBuilder getPreController(String url, final PhotoDraweeView draweeView) {
    ImageRequest request = ImageRequestBuilder.newBuilderWithSource(Uri.parse(url))
            .setProgressiveRenderingEnabled(true)
            .build();

    PipelineDraweeControllerBuilder controller = Fresco.newDraweeControllerBuilder();
    controller.setImageRequest(request);
    controller.setOldController(draweeView.getController());
    controller.setAutoPlayAnimations(true);
    return controller;
}
项目:SprintNBA    文件:ImagePreFragment.java   
private void initImage() {
    PipelineDraweeControllerBuilder controller = FrescoUtils.getPreController(url, pdvImage);
    controller.setControllerListener(listener);
    final GenericDraweeHierarchy hierarchy = new GenericDraweeHierarchyBuilder(getResources())
            .setProgressBarImage(new ImageLoadProgressBar(new ImageLoadProgressBar.OnLevelChangeListener() {
                @Override
                public void onChange(int level) {
                    if (level >= 100) {
                        hideLoadingDialog();
                    }
                }
            }, Color.parseColor("#90CCCCCC"))).build();
    hierarchy.setActualImageScaleType(ScalingUtils.ScaleType.FIT_CENTER);
    pdvImage.setHierarchy(hierarchy);
    pdvImage.setController(controller.build());
    pdvImage.setOnPhotoTapListener(new OnPhotoTapListener() {
        @Override
        public void onPhotoTap(View view, float x, float y) {
            if (mActivity != null)
                mActivity.finish();
        }
    });
    pdvImage.setOnLongClickListener(new View.OnLongClickListener() {
        @Override
        public boolean onLongClick(View v) {

            return true;
        }
    });
}
项目:AyoSunny    文件:ViewPagerActivity.java   
@Override public Object instantiateItem(ViewGroup viewGroup, int position) {
    final PhotoDraweeView photoDraweeView = new PhotoDraweeView(viewGroup.getContext());
    PipelineDraweeControllerBuilder controller = Fresco.newDraweeControllerBuilder();
    controller.setUri(Uri.parse("res:///" + mDrawables[position]));

    if(position == 1){
        String uri1 = "http://git.oschina.net/biezhihua/MyResource/raw/master/25-173250_974.gif ";
        String uri2 = "http://img5.duitang.com/uploads/item/201511/04/20151104214718_FfnST.jpeg";
        controller.setUri(Uri.parse(uri1));
    }

    controller.setOldController(photoDraweeView.getController());
    controller.setControllerListener(new BaseControllerListener<ImageInfo>() {
        @Override
        public void onFinalImageSet(String id, ImageInfo imageInfo, Animatable animatable) {
            super.onFinalImageSet(id, imageInfo, animatable);
            if (imageInfo == null) {
                return;
            }
            photoDraweeView.update(imageInfo.getWidth(), imageInfo.getHeight());

            if(animatable != null){
                animatable.start();
            }
        }
    });
    photoDraweeView.setController(controller.build());

    try {
        viewGroup.addView(photoDraweeView, ViewGroup.LayoutParams.MATCH_PARENT,
                ViewGroup.LayoutParams.MATCH_PARENT);
    } catch (Exception e) {
        e.printStackTrace();
    }

    return photoDraweeView;
}
项目:AyoSunny    文件:AyoGalleryFragment.java   
@Override public Object instantiateItem(ViewGroup viewGroup, int position) {

            IImageInfo bean = images.get(position);
            final PhotoDraweeView photoDraweeView = new PhotoDraweeView(viewGroup.getContext());
            PipelineDraweeControllerBuilder controller = Fresco.newDraweeControllerBuilder();
            controller.setUri(Uri.parse(bean.getUri()));
            controller.setOldController(photoDraweeView.getController());
            controller.setControllerListener(new BaseControllerListener<ImageInfo>() {
                @Override
                public void onFinalImageSet(String id, ImageInfo imageInfo, Animatable animatable) {
                    super.onFinalImageSet(id, imageInfo, animatable);
                    if (imageInfo == null) {
                        return;
                    }
                    photoDraweeView.update(imageInfo.getWidth(), imageInfo.getHeight());

                    if(animatable != null){
                        animatable.start();
                    }
                }
            });
            photoDraweeView.setController(controller.build());

            try {
                viewGroup.addView(photoDraweeView, ViewGroup.LayoutParams.MATCH_PARENT,
                        ViewGroup.LayoutParams.MATCH_PARENT);
            } catch (Exception e) {
                e.printStackTrace();
            }

            return photoDraweeView;
        }
项目:SneezeReader    文件:WrapContentDraweeView.java   
@Override
public void setImageURI(Uri uri, Object callerContext) {
    DraweeController controller = ((PipelineDraweeControllerBuilder)getControllerBuilder())
            .setControllerListener(controllerListener)
            .setCallerContext(callerContext)
            .setUri(uri)
            .setOldController(getController())
            .build();
    setController(controller);
}
项目:redgram-for-reddit    文件:PostItemGalleryView.java   
private DraweeController getDraweeController(PostItem item) {
    Uri thumbnailUri = Uri.parse(item.getThumbnail());
    ImageRequest thumbnail = ImageRequestBuilder.newBuilderWithSource(thumbnailUri)
            .build();

    PipelineDraweeControllerBuilder builder = Fresco.newDraweeControllerBuilder()
            .setImageRequest(thumbnail)
            .setOldController(thumbnailView.getController());
    return builder.build();
}
项目:redgram-for-reddit    文件:PostItemAnimatedView.java   
private DraweeController getDraweeController(PostItem item) {
    Uri thumbnailUri = Uri.parse(item.getThumbnail());
    ImageRequest thumbnail = ImageRequestBuilder.newBuilderWithSource(thumbnailUri)
            .build();

    PipelineDraweeControllerBuilder builder = Fresco.newDraweeControllerBuilder()
            .setImageRequest(thumbnail)
            .setOldController(thumbnailView.getController());

    return builder.build();
}
项目:TLint    文件:ImageFragment.java   
@Override
public void initData() {
    showContent(true);
    ImageRequest request = ImageRequestBuilder.newBuilderWithSource(Uri.parse(url))
            .setProgressiveRenderingEnabled(true)
            .build();

    GenericDraweeHierarchy hierarchy =
            new GenericDraweeHierarchyBuilder(getResources()).setProgressBarImage(
                    new ImageLoadProgressBar(new ImageLoadProgressBar.OnLevelChangeListener() {
                        @Override
                        public void onChange(int level) {
                            if (level > 100 && progress.getVisibility() == View.VISIBLE) {
                                progress.setVisibility(View.GONE);
                            }
                        }
                    }, ResourceUtil.getThemeColor(getActivity()))).build();
    hierarchy.setActualImageScaleType(ScalingUtils.ScaleType.FIT_CENTER);

    PipelineDraweeControllerBuilder controller = Fresco.newDraweeControllerBuilder();
    controller.setControllerListener(listener);
    controller.setImageRequest(request);
    controller.setOldController(image.getController());
    controller.setAutoPlayAnimations(true);
    image.setHierarchy(hierarchy);
    image.setController(controller.build());
}
项目:fresco    文件:DraweeViewListAdapter.java   
@Override
public View getView(int position, View convertView, ViewGroup parent) {
  InstrumentedDraweeView draweeView;
  if (convertView == null) {
    final Context context = parent.getContext();
    GenericDraweeHierarchy gdh = DraweeUtil.createDraweeHierarchy(context, mConfig);
    draweeView = new InstrumentedDraweeView(context, gdh, mConfig);
    SizeUtil.setConfiguredSize(parent, draweeView, mConfig);
    draweeView.setPadding(mPaddingPx, mPaddingPx, mPaddingPx, mPaddingPx);
  } else {
    draweeView = (InstrumentedDraweeView) convertView;
  }
  final Uri uri = getItem(position);
  draweeView.initInstrumentation(uri.toString(), mPerfListener);
  ImageRequestBuilder imageRequestBuilder = ImageRequestBuilder
          .newBuilderWithSource(uri)
          .setResizeOptions(
                  new ResizeOptions(
                          draweeView.getLayoutParams().width,
                          draweeView.getLayoutParams().height));
  PipelineUtil.addOptionalFeatures(imageRequestBuilder, mConfig);
  // Create the Builder
  PipelineDraweeControllerBuilder builder = Fresco.newDraweeControllerBuilder()
          .setImageRequest(imageRequestBuilder.build());
  if (mConfig.reuseOldController) {
    builder.setOldController(draweeView.getController());
  }
  if (mConfig.instrumentationEnabled) {
    draweeView.setListener(builder);
  }
  draweeView.setController(builder.build());
  return draweeView;
}
项目:FrescoPlus    文件:FrescoPlusCore.java   
/**
 * @return create a new DraweeControllerBuilder instance.
 */
public static PipelineDraweeControllerBuilder newDraweeControllerBuilder() {
    ParamCheckUtil.checkNotNull(mDraweeControllerBuilderSupplier,"FrescoPlusCore not initialize");
    return mDraweeControllerBuilderSupplier.get();
}
项目:zSMTH-Android    文件:WrapContentDraweeView.java   
@Override public void setImageURI(Uri uri, Object callerContext) {
  // http://frescolib.org/docs/modifying-image.html
  // this post process will do two things: 1. resize if image width is too large; 2. split if image height is too large
  Postprocessor postProcessor = new BasePostprocessor() {
    @Override public String getName() {
      return "SplitLongImagePostProcessor";
    }

    @Override public CloseableReference<Bitmap> process(Bitmap sourceBitmap, PlatformBitmapFactory bitmapFactory) {
      CloseableReference<Bitmap> bitmapRef = null;

      try {
        // resize image if its width is too large: > windowWidth * 1.5
        double ratio = 1.0;
        if (sourceBitmap.getWidth() >= WindowWidth * 1.5) {
          ratio = (double) WindowWidth / sourceBitmap.getWidth();
        }
        bitmapRef = bitmapFactory.createBitmap((int) (sourceBitmap.getWidth() * ratio), (int) (sourceBitmap.getHeight() * ratio));

        Bitmap destBitmap = bitmapRef.get();
        Canvas canvas = new Canvas(destBitmap);
        Rect destRect = new Rect(0, 0, destBitmap.getWidth(), destBitmap.getHeight());
        canvas.drawBitmap(sourceBitmap, null, destRect, paint);

        // split images if its height is too large: > OpenGL max Height
        try {
          int imageTotalHeight = destBitmap.getHeight();
          double imageAspectRatio = destBitmap.getWidth() / (double) WindowWidth;
          int imageMaxAllowedHeight;
          if (imageAspectRatio < 1) {
            imageMaxAllowedHeight = (int) (ImageUtils.getMaxHeight() * imageAspectRatio) - 5;
          } else {
            imageMaxAllowedHeight = ImageUtils.getMaxHeight() - 5;
          }
          int imageCount = getTimes(imageTotalHeight, imageMaxAllowedHeight);
          //                        Log.d(TAG, "process: h = " + imageTotalHeight + " w = " + destBitmap.getWidth() + " allowed: " + imageMaxAllowedHeight + " count: " + imageCount);
          if (imageCount > 1) {
            bmps = new ArrayList<Bitmap>();
            Rect bsrc = new Rect();

            ByteArrayOutputStream baos = new ByteArrayOutputStream();
            destBitmap.compress(Bitmap.CompressFormat.JPEG, 100, baos);
            InputStream isBm = new ByteArrayInputStream(baos.toByteArray());
            BitmapRegionDecoder decoder = BitmapRegionDecoder.newInstance(isBm, true);
            for (int i = 0; i < imageCount; i++) {
              bsrc.left = 0;
              bsrc.top = i * imageMaxAllowedHeight;
              bsrc.right = destBitmap.getWidth();
              bsrc.bottom = Math.min(bsrc.top + imageMaxAllowedHeight, imageTotalHeight);
              Bitmap bmp = decoder.decodeRegion(bsrc, null);
              bmps.add(bmp);
            }
          }
        } catch (Exception e) {
          Log.e(TAG, Log.getStackTraceString(e));
        }
        return CloseableReference.cloneOrNull(bitmapRef);
      } finally {
        CloseableReference.closeSafely(bitmapRef);
      }
    }
  };

  ImageRequest request = ImageRequestBuilder.newBuilderWithSource(uri).setAutoRotateEnabled(true)
      // this will reduce image's size if it's wider than screen width
      //                .setResizeOptions(new ResizeOptions(WindowWidth, Integer.MAX_VALUE))
      .setPostprocessor(postProcessor).build();

  DraweeController controller = ((PipelineDraweeControllerBuilder) getControllerBuilder()).setImageRequest(request)
      .setControllerListener(listener)
      .setCallerContext(callerContext)
      .setAutoPlayAnimations(true)
      .setOldController(getController())
      .build();
  setController(controller);
}
项目:redgram-for-reddit    文件:ImageManager.java   
private static PipelineDraweeControllerBuilder getControllerBuilderInstance(){
    return Fresco.newDraweeControllerBuilder();
}
项目:redgram-for-reddit    文件:ImageManager.java   
public SingleImageBuilder setControllerBuilder(PipelineDraweeControllerBuilder controllerBuilder) {
    this.controllerBuilder = controllerBuilder;
    return this;
}
项目:redgram-for-reddit    文件:ImageManager.java   
public PipelineDraweeControllerBuilder getControllerBuilder() {
    return controllerBuilder;
}
项目:FrescoCustomCacheKey    文件:FrescoImageLoader.java   
/**
 * 获取DraweeController
 *
 * @param imageRequest 设置单个图片请求
 */
public static PipelineDraweeControllerBuilder getDraweeController(SimpleDraweeView view, ImageRequest imageRequest) {
    return getDraweeController(view, imageRequest, null, false);
}
项目:FrescoCustomCacheKey    文件:FrescoImageLoader.java   
/**
 * 获取DraweeController
 *
 * @param imageRequest 设置单个图片请求
 * @param controllerListener 监听图片下载完毕等
 */
public static PipelineDraweeControllerBuilder getDraweeController(SimpleDraweeView view, ImageRequest imageRequest, @Nullable ControllerListener<ImageInfo> controllerListener) {
    return getDraweeController(view, imageRequest, null, null, controllerListener, false);
}
项目:FrescoCustomCacheKey    文件:FrescoImageLoader.java   
/**
 * 获取DraweeController
 *
 * @param imageRequest 高分辨率的图
 * @param lowResImageRequest 低分辨率的图
 */
public static PipelineDraweeControllerBuilder getDraweeController(SimpleDraweeView view, ImageRequest imageRequest, @Nullable ImageRequest lowResImageRequest) {
    return getDraweeController(view, imageRequest, lowResImageRequest, null, null, false);
}
项目:FrescoCustomCacheKey    文件:FrescoImageLoader.java   
/**
 * 获取DraweeController
 *
 * @param imageRequest 高分辨率的图
 * @param lowResImageRequest 低分辨率的图
 * @param tapToRetryEnabled 点击重新加载图
 */
public static PipelineDraweeControllerBuilder getDraweeController(SimpleDraweeView view, ImageRequest imageRequest, @Nullable ImageRequest lowResImageRequest, boolean tapToRetryEnabled) {
    return getDraweeController(view, imageRequest, lowResImageRequest, null, null, tapToRetryEnabled);
}
项目:FrescoCustomCacheKey    文件:FrescoImageLoader.java   
/**
 * 获取DraweeController
 *
 * @param firstAvailableImageRequests 本地图片复用,可加入ImageRequest数组
 */
public static PipelineDraweeControllerBuilder getDraweeController(SimpleDraweeView view, @Nullable ImageRequest[] firstAvailableImageRequests) {
    return getDraweeController(view, null, null, firstAvailableImageRequests, null, false);
}