Java 类com.facebook.imagepipeline.request.ImageRequestBuilder 实例源码

项目:GitHub    文件:ImageFormatOverrideExample.java   
@Override
public void onViewCreated(View view, @Nullable Bundle savedInstanceState) {
  SimpleDraweeView simpleDraweeView = (SimpleDraweeView) view.findViewById(R.id.drawee_view);

  ImageDecodeOptions imageDecodeOptionsWithCustomDecoder = new ImageDecodeOptionsBuilder()
      .setCustomImageDecoder(CUSTOM_COLOR_DECODER)
      .build();

  AbstractDraweeController controller = Fresco.newDraweeControllerBuilder()
      .setImageRequest(
          ImageRequestBuilder.newBuilderWithResourceId(R.raw.custom_color1)
              .setImageDecodeOptions(imageDecodeOptionsWithCustomDecoder)
              .build())
      .build();
  simpleDraweeView.setController(controller);
}
项目:GitHub    文件:FrescoHolder.java   
@Override
protected void onBind(String uriString) {
  Uri uri = Uri.parse(uriString);
  ImageRequestBuilder imageRequestBuilder =
      ImageRequestBuilder.newBuilderWithSource(uri);
  if (UriUtil.isNetworkUri(uri)) {
    imageRequestBuilder.setProgressiveRenderingEnabled(true);
  } else {
    imageRequestBuilder.setResizeOptions(new ResizeOptions(
        mImageView.getLayoutParams().width,
        mImageView.getLayoutParams().height));
  }
  DraweeController draweeController = Fresco.newDraweeControllerBuilder()
      .setImageRequest(imageRequestBuilder.build())
      .setOldController(mImageView.getController())
      .setControllerListener(mImageView.getListener())
      .setAutoPlayAnimations(true)
      .build();
  mImageView.setController(draweeController);
}
项目:GitHub    文件:MediaVariationsFragment.java   
private void loadThumb(
    SimpleDraweeView draweeView,
    Size size,
    ImageRequest.RequestLevel requestLevel) {
  ImageRequest request = ImageRequestBuilder.newBuilderWithSource(size.uri)
      .setMediaVariations(MediaVariations.newBuilderForMediaId(MEDIA_ID)
          .setForceRequestForSpecifiedUri(true)
          .build())
      .setLowestPermittedRequestLevel(requestLevel)
      .setResizeOptions(new ResizeOptions(draweeView.getWidth(), draweeView.getHeight()))
      .setCacheChoice(size.cacheChoice)
      .build();
  DraweeController controller = Fresco.newDraweeControllerBuilder()
      .setImageRequest(request)
      .setOldController(draweeView.getController())
      .build();
  draweeView.setController(controller);
}
项目:GitHub    文件:MediaVariationsFragment.java   
private void loadMainImage() {
  // Request a non-existent image to force fallback to the variations
  Uri uri = Uri.parse(String.format(URI_TEMPLATE, "full", "jpg"));
  ImageRequest request = ImageRequestBuilder.newBuilderWithSource(uri)
      .setMediaVariations(getMediaVariationsForMode(mMode))
      .setResizeOptions(new ResizeOptions(
          mMainImageDraweeView.getWidth(),
          mMainImageDraweeView.getHeight()))
      .build();

  Log.i(
      TAG,
      request.getMediaVariations() == null ? "null" : request.getMediaVariations().toString());

  setDraweeControllerForRequest(request);
}
项目: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());
}
项目:GitHub    文件:PipelineUtil.java   
/**
 * Utility method which adds optional configuration to ImageRequest
 *
 * @param imageRequestBuilder The Builder for ImageRequest
 * @param config              The Config
 */
public static void addOptionalFeatures(ImageRequestBuilder imageRequestBuilder, Config config) {
  if (config.usePostprocessor) {
    final Postprocessor postprocessor;
    switch (config.postprocessorType) {
      case "use_slow_postprocessor":
        postprocessor = DelayPostprocessor.getMediumPostprocessor();
        break;
      case "use_fast_postprocessor":
        postprocessor = DelayPostprocessor.getFastPostprocessor();
        break;
      default:
        postprocessor = DelayPostprocessor.getMediumPostprocessor();
    }
    imageRequestBuilder.setPostprocessor(postprocessor);
  }
  if (config.rotateUsingMetaData) {
    imageRequestBuilder.setRotationOptions(RotationOptions.autoRotateAtRenderTime());
  } else {
    imageRequestBuilder
        .setRotationOptions(RotationOptions.forceRotation(config.forcedRotationAngle));
  }
}
项目: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 void layoutChildrenView() {
    int childrenCount = getChildCount();

    for (int i = 0; i < childrenCount; i++) {
        ViewGroup childImageLayout = (ViewGroup) getChildAt(i);
        SimpleDraweeView childImageView = (SimpleDraweeView) childImageLayout.getChildAt(0);
        if (mOnItemClickListener != null) {
            final int finalI = i;
            childImageLayout.setOnClickListener(new OnClickListener() {
                @Override
                public void onClick(View v) {
                    mOnItemClickListener.OnItemClick(finalI);
                }
            });
        }
        ImageRequest request = ImageRequestBuilder.newBuilderWithSource(Uri.parse(mImageUrls.get(i)))
                .setProgressiveRenderingEnabled(true)
                .setResizeOptions(new ResizeOptions(mItemWidth, mItemWidth))
                .build();
        DraweeController controller = Fresco.newDraweeControllerBuilder()
                .setImageRequest(request)
                .setOldController(childImageView.getController())
                .build();
        childImageView.setController(controller);

        int[] position = findPosition(i);
        int itemHeight = mItemWidth;
        int left = (int) (mItemWidth + mHorizontalSpace) * position[1];
        int top = (int) (itemHeight + mVerticalSpace) * position[0];
        int right = left + mItemWidth;
        int bottom = top + itemHeight;

        childImageLayout.layout(left, top, right, bottom);
    }
}
项目:CommentGallery    文件:CommentImageGrid.java   
private void refreshImageChild() {
    int childrenCount = getChildCount();
    if (childrenCount > 0) {
        for (int i = 0; i < childrenCount; i++) {
            ViewGroup childImageLayout = (ViewGroup) getChildAt(i);
            SimpleDraweeView childImageView = (SimpleDraweeView) childImageLayout.getChildAt(0);
            if (mOnItemClickListener != null) {
                final int finalI = i;
                childImageLayout.setOnClickListener(new OnClickListener() {
                    @Override
                    public void onClick(View v) {
                        mOnItemClickListener.OnItemClick(finalI);
                    }
                });
            }
            ImageRequest request = ImageRequestBuilder.newBuilderWithSource(Uri.parse(mImageUrls.get(i)))
                    .setResizeOptions(new ResizeOptions(mItemWidth, mItemWidth))
                    .build();
            DraweeController controller = Fresco.newDraweeControllerBuilder()
                    .setImageRequest(request)
                    .setOldController(childImageView.getController())
                    .build();
            childImageView.setController(controller);
        }
    }
}
项目:cardinalsSample    文件:FrescoManager.java   
public void display(SimpleDraweeView view, String url, Postprocessor postprocessor) {
    if (!TextUtils.isEmpty(url)) {
        Uri uri;
        if (URLUtil.isNetworkUrl(url)) {
            uri = Uri.parse(url);
        } else {
            uri = Uri.fromFile(new File(url));
        }
        ImageRequest request = ImageRequestBuilder
                .newBuilderWithSource(uri)
                .setPostprocessor(postprocessor)
                .setProgressiveRenderingEnabled(true)
                //.setResizeOptions(new ResizeOptions(100, 100))
                .setLocalThumbnailPreviewsEnabled(true)
                .setRotationOptions(RotationOptions.autoRotateAtRenderTime())
                .build();

        controller = Fresco.newDraweeControllerBuilder()
                .setImageRequest(request)
                .setOldController(view.getController())
                .build();
        view.setController(controller);

    }

}
项目:PicKing    文件:FrescoUtil.java   
public static void setBlurFrescoController(SimpleDraweeView simpleDraweeView, String url, int iterations, int blurRadius) {
    try {
        Uri uri = Uri.parse(url);
        ImageRequest request = ImageRequestBuilder.newBuilderWithSource(uri)
                .setPostprocessor(new IterativeBoxBlurPostProcessor(iterations, blurRadius))
                .build();
        DraweeController controller = Fresco.newDraweeControllerBuilder()
                .setOldController(simpleDraweeView.getController())
                .setImageRequest(request)
                .build();
        simpleDraweeView.setController(controller);
    } catch (Exception e) {
        e.printStackTrace();
    }

}
项目:Watermark    文件:FrescoImageLoader.java   
public static void setImageSmall(String url,
                                 SimpleDraweeView simpleDraweeView,
                                 int width,
                                 int height,
                                 SquareRelativeLayout relativeLayout, boolean playGif) {

    Uri uri = Uri.parse(url);
    ImageRequest request = ImageRequestBuilder
            .newBuilderWithSource(uri)
            .setRotationOptions(RotationOptions.autoRotate())
            .setResizeOptions(new ResizeOptions(width, height))
            .setLowestPermittedRequestLevel(ImageRequest.RequestLevel.FULL_FETCH)
            .build();
    DraweeController controller = Fresco.newDraweeControllerBuilder()
            .setTapToRetryEnabled(true)
            .setImageRequest(request)
            .setAutoPlayAnimations(playGif)
            .setOldController(simpleDraweeView.getController())
            .build();
    relativeLayout.setLayoutParams(new RelativeLayout.LayoutParams(width - 5, height));
    simpleDraweeView.setController(controller);
}
项目:tumbviewer    文件:SettingsActivity.java   
@Override
public void bindView(TumblrAccount account) {
    this.account = account;
    if (account.isUsing()) {
        checkedView.setVisibility(View.VISIBLE);
    } else {
        checkedView.setVisibility(View.GONE);
    }
    if (!TextUtils.isEmpty(account.getName())) {
        nameView.setText(account.getName());
        FrescoUtils.setTumblrAvatarUri(avatarView, account.getName(), 128);
    } else {
        nameView.setText(getResources().getString(R.string.settings_accounts_title,
                getAdapterPosition() + 1));
        ImageRequest imageRequest = ImageRequestBuilder
                .newBuilderWithResourceId(R.mipmap.ic_account_default).build();
        avatarView.setImageURI(imageRequest.getSourceUri());
    }
    keyView.setText(account.getApiKey());
}
项目:ModuleFrame    文件:FrescoUtil.java   
/**
 * 指定控件
 *
 * @param simpleDraweeView
 */
public void into(@NonNull SimpleDraweeView simpleDraweeView) {
    ImageRequestBuilder imageRequestBuilder = ImageRequestBuilder.newBuilderWithSource(uri);

    if (resizeOptions != null) {
        imageRequestBuilder.setResizeOptions(resizeOptions);
    }
    if (postprocessor != null) {
        imageRequestBuilder.setPostprocessor(postprocessor);
    }
    if (priority != null) {
        imageRequestBuilder.setRequestPriority(priority);
    }

    DraweeController controller = Fresco.newDraweeControllerBuilder()
            .setImageRequest(imageRequestBuilder.build())
            .setOldController(simpleDraweeView.getController())
            .build();
    simpleDraweeView.setController(controller);
}
项目:Blockbuster    文件:MovieGalleryAdapter.java   
private void setupItemImage(SimpleDraweeView imageView, Uri imageUrl, boolean isVertical) {
        ImageRequest request = ImageRequestBuilder.newBuilderWithSource(imageUrl)
                .setProgressiveRenderingEnabled(true)
                .build();
        DraweeController controller = Fresco.newDraweeControllerBuilder()
                .setImageRequest(request)
                .setOldController(imageView.getController())
                .build();
        imageView.setController(controller);

       // imageView.setLayoutParams(new RelativeLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, (int) context.getResources().getDimension(R.dimen.poster_grid2_height)));

        final RelativeLayout.LayoutParams lp =
                    (RelativeLayout.LayoutParams) imageView.getLayoutParams();

//
            if (!isVertical) {
                lp.height = ViewGroup.LayoutParams.MATCH_PARENT;
                lp.width = (recyclerView.getMeasuredHeight()/3)*2/3;
            } else {
                lp.height = recyclerView.getMeasuredWidth()/2;
                lp.width = ViewGroup.LayoutParams.MATCH_PARENT;
            }
            imageView.setLayoutParams(lp);
    }
项目:react-native-amap    文件:AMapMarker.java   
public void setImage(String uri) {
    if (uri == null) {
        iconBitmapDescriptor = null;
        update();
    } else if (uri.startsWith("http://") || uri.startsWith("https://") ||
            uri.startsWith("file://")) {
        ImageRequest imageRequest = ImageRequestBuilder
                .newBuilderWithSource(Uri.parse(uri))
                .build();

        ImagePipeline imagePipeline = Fresco.getImagePipeline();
        dataSource = imagePipeline.fetchDecodedImage(imageRequest, this);
        DraweeController controller = Fresco.newDraweeControllerBuilder()
                .setImageRequest(imageRequest)
                .setControllerListener(mLogoControllerListener)
                .setOldController(logoHolder.getController())
                .build();
        logoHolder.setController(controller);
    } else {
        iconBitmapDescriptor = getBitmapDescriptorByName(uri);
        update();
    }
}
项目:fastDev    文件:FrescoUtils.java   
public static void load(Uri uri,SimpleDraweeView draweeView,BasePostprocessor processor,int width,int height,
                        BaseControllerListener listener){
    ImageRequest request =
            ImageRequestBuilder.newBuilderWithSource(uri)
                    .setPostprocessor(processor)
                    .setResizeOptions(new ResizeOptions(width,height))
                    //缩放,在解码前修改内存中的图片大小, 配合Downsampling可以处理所有图片,否则只能处理jpg,
                    // 开启Downsampling:在初始化时设置.setDownsampleEnabled(true)
                    .setProgressiveRenderingEnabled(true)//支持图片渐进式加载
                    .setAutoRotateEnabled(true) //如果图片是侧着,可以自动旋转
                    .build();

    PipelineDraweeController controller =
            (PipelineDraweeController) Fresco.newDraweeControllerBuilder()
                    .setImageRequest(request)
                    .setControllerListener(listener)
                    .setOldController(draweeView.getController())
                    .setAutoPlayAnimations(true) //自动播放gif动画
                    .build();

    draweeView.setController(controller);
}
项目:CanPhotos    文件:CanPhotoHelper.java   
/**
 * 设置图片
 *
 * @param image
 * @param url
 * @param width
 * @param heigth
 */
public void setDraweeImage(SimpleDraweeView image, String url, int width, int heigth) {


    if (width <= 0) {
        width = dp2Px(image.getContext(), 50);
    }
    if (heigth <= 0) {
        heigth = dp2Px(image.getContext(), 50);
    }

    ImageRequest imageRequest = ImageRequestBuilder.newBuilderWithSource(Uri.parse(url)).setLocalThumbnailPreviewsEnabled(true).setResizeOptions(new ResizeOptions(width, heigth)).build();
    DraweeController draweeController = Fresco.newDraweeControllerBuilder()
            .setImageRequest(imageRequest)
            .setAutoPlayAnimations(true)
            .build();
    image.setController(draweeController);

}
项目:FrescoCustomCacheKey    文件:FrescoImageLoader.java   
public static LJImageRequest getImageRequest(SimpleDraweeView view, String uri, String cacheKey, @Nullable ImageRequest.CacheChoice cacheChoice) {
    if (cacheChoice == null) {
        cacheChoice = ImageRequest.CacheChoice.DEFAULT;
    }

    LJImageRequestBuilder builder = LJImageRequestBuilder
            .newBuilderWithSource(Uri.parse(uri), cacheKey);
    ImageRequestBuilder requestBuilder = builder.getImageRequestBuilder();
    requestBuilder.setAutoRotateEnabled(true)//自动旋转图片方向
                  .setCacheChoice(cacheChoice)//图片类型,设置后可调整图片放入小图磁盘空间还是默认图片磁盘空间
                  .setLocalThumbnailPreviewsEnabled(true)//缩略图预览,影响图片显示速度(轻微)
                  .setLowestPermittedRequestLevel(ImageRequest.RequestLevel.FULL_FETCH)//请求经过缓存级别
                  .setProgressiveRenderingEnabled(true);//渐进加载,主要用于渐进式的JPEG图,影响图片显示速度(普通)

    ViewGroup.LayoutParams layoutParams = view.getLayoutParams();
    if (layoutParams != null && layoutParams.width > 0 &&
            layoutParams.height > 0) {
        ResizeOptions resizeOptions = new ResizeOptions(layoutParams.width, layoutParams.height);
        requestBuilder.setResizeOptions(resizeOptions);//调整图片大小
    }

    return builder.build();
}
项目:FrescoCustomCacheKey    文件:LJImageRequestBuilder.java   
/**
 * Creates a new request builder instance with the same parameters as the
 * imageRequest passed in.
 *
 * @param imageRequest the ImageRequest from where to copy the parameters
 * to
 * the builder.
 * @return a new request builder instance
 */
public static LJImageRequestBuilder fromRequest(LJImageRequest imageRequest) {
    ImageRequestBuilder imageRequestBuilder = ImageRequestBuilder
            .newBuilderWithSource(imageRequest.getSourceUri())
            .setAutoRotateEnabled(imageRequest.getAutoRotateEnabled())
            .setImageDecodeOptions(imageRequest.getImageDecodeOptions())
            .setCacheChoice(imageRequest.getCacheChoice())
            .setLocalThumbnailPreviewsEnabled(imageRequest
                    .getLocalThumbnailPreviewsEnabled())
            .setLowestPermittedRequestLevel(imageRequest
                    .getLowestPermittedRequestLevel())
            .setPostprocessor(imageRequest.getPostprocessor())
            .setProgressiveRenderingEnabled(imageRequest
                    .getProgressiveRenderingEnabled())
            .setRequestPriority(imageRequest.getPriority())
            .setResizeOptions(imageRequest.getResizeOptions());
    return new LJImageRequestBuilder(imageRequestBuilder, imageRequest
            .getCacheKey());
}
项目:android-base    文件:FrescoUtils.java   
/**
 * showThumb
 *
 * @param draweeView     draweeView
 * @param url            url
 * @param resizeWidthDp  resizeWidth
 * @param resizeHeightDp resizeHeight
 */
public static void showThumb(SimpleDraweeView draweeView, String url, int resizeWidthDp, int resizeHeightDp) {
    try {
        if (!isInit)
            return;
        if (url == null || "".equals(url))
            return;
        if (draweeView == null)
            return;
        initialize(draweeView.getContext());
        ImageRequest request = ImageRequestBuilder.newBuilderWithSource(Uri.parse(url))
                .setResizeOptions(new ResizeOptions(DimenUtils.dip2px(draweeView.getContext(), resizeWidthDp), DimenUtils.dip2px(draweeView.getContext(), resizeHeightDp)))
                .build();
        DraweeController controller = Fresco.newDraweeControllerBuilder()
                .setImageRequest(request)
                .setOldController(draweeView.getController())
                .setControllerListener(new BaseControllerListener<ImageInfo>())
                .build();
        draweeView.setController(controller);
    } catch (Exception e) {
    }
}
项目:H-Viewer    文件:ImageLoader.java   
public static void loadBitmapFromUrl(Context context, String url, String cookie, String referer, BaseBitmapDataSubscriber dataSubscriber) {
    if (TextUtils.isEmpty(url))
        return;
    Uri uri = Uri.parse(url);
    JsonObject header = new JsonObject();
    header.addProperty("Cookie", cookie);
    header.addProperty("Referer", referer);
    if (HProxy.isEnabled() && HProxy.isAllowPicture()) {
        HProxy proxy = new HProxy(url);
        header.addProperty(proxy.getHeaderKey(), proxy.getHeaderValue());
    }
    MyOkHttpNetworkFetcher.headers.put(uri, getGson().toJson(header));
    ImagePipeline imagePipeline = Fresco.getImagePipeline();
    ImageRequestBuilder builder = ImageRequestBuilder.newBuilderWithSource(uri);
    ImageRequest request = builder.build();
    DataSource<CloseableReference<CloseableImage>>
            dataSource = imagePipeline.fetchDecodedImage(request, context);
    dataSource.subscribe(dataSubscriber, CallerThreadExecutor.getInstance());
}
项目:H-Viewer    文件:ImageLoader.java   
public static void loadResourceFromUrl(Context context, Uri uri, String cookie, String referer, BaseDataSubscriber dataSubscriber) {
    if (uri.getScheme().startsWith("http")) {
        JsonObject header = new JsonObject();
        header.addProperty("Cookie", cookie);
        header.addProperty("Referer", referer);
        if (HProxy.isEnabled() && HProxy.isAllowPicture()) {
            HProxy proxy = new HProxy(uri.toString());
            header.addProperty(proxy.getHeaderKey(), proxy.getHeaderValue());
        }
        MyOkHttpNetworkFetcher.headers.put(uri, getGson().toJson(header));
    }
    ImagePipeline imagePipeline = Fresco.getImagePipeline();
    ImageRequestBuilder builder = ImageRequestBuilder.newBuilderWithSource(uri);
    ImageRequest request = builder.build();
    DataSource<CloseableReference<PooledByteBuffer>>
            dataSource = imagePipeline.fetchEncodedImage(request, context);
    dataSource.subscribe(dataSubscriber, CallerThreadExecutor.getInstance());
}
项目:APlayer    文件:AsynLoadImage.java   
@Override
protected void onPostExecute(String url) {
    if(mImage != null && !TextUtils.isEmpty(url)) {
        if(mImage.getTag() != null && mImage.getTag().equals(url)){
            return;
        }

        DraweeController controller = Fresco.newDraweeControllerBuilder()
                .setImageRequest(ImageRequestBuilder.newBuilderWithSource(Uri.parse(url))
                        .build())
                .setOldController(mImage.getController())
                .build();

        mImage.setController(controller);
        mImage.setTag(url);
    }
}
项目:videoPickPlayer    文件:VideoAdapter.java   
public void setFrescoImage(SimpleDraweeView frescoImage, String url , int w, int h){
        if (isNull(url)){
//            frescoImage.setImageURI(Uri.parse("" + R.drawable.fallload));
            frescoImage.setImageResource(R.drawable.fallload);
            return;
        }
//        int width = ScreenUtil.dip2px(w), height = ScreenUtil.dip2px(h);
        if (!url.startsWith("http")){
            url = "file://"+url;
        }
//        showErrorLog(url);
        Uri uri = Uri.parse(url);
//        frescoImage.setImageURI(uri);
        ImageRequest request = ImageRequestBuilder.newBuilderWithSource(uri)
                .setResizeOptions(new ResizeOptions(w, h))
                .build();
        PipelineDraweeController controller = (PipelineDraweeController) Fresco.newDraweeControllerBuilder()
                .setOldController(frescoImage.getController())
                .setImageRequest(request)
                .build();
        frescoImage.setController(controller);
    }
项目:android-upload-service    文件:Adapter.java   
public void bind(Item item){
  Uri uri = item.getUri();

  filename.setText(uri.toString());

  DraweeController controller = Fresco.newDraweeControllerBuilder()
      .setImageRequest(ImageRequestBuilder.newBuilderWithSource(uri).setResizeOptions(new ResizeOptions(width, height)).build())
      .setAutoPlayAnimations(true)
      .setOldController(image.getController())
      .setTapToRetryEnabled(true)
      .build();
  image.setController(controller);

  if(item.isCloud()){
    cloud.setImageResource(R.drawable.ic_cloud);
  }else{
    cloud.setImageResource(R.drawable.ic_cloud_off);
  }
}
项目:android-jungle-framework    文件:FrescoImageLoaderEngine.java   
private DraweeController createDraweeController(
        DraweeView draweeView, Uri uri, ControllerListener<ImageInfo> listener) {

    JungleSize size = ImageLoaderUtils.getAppropriateSize(draweeView);
    ImageRequest request = ImageRequestBuilder
            .newBuilderWithSource(uri)
            .setResizeOptions(new ResizeOptions(size.mWidth, size.mHeight))
            .setAutoRotateEnabled(true)
            .build();

    return Fresco.newDraweeControllerBuilder()
            .setUri(uri)
            .setImageRequest(request)
            .setControllerListener(listener)
            .setAutoPlayAnimations(true)
            .setOldController(draweeView.getController())
            .build();
}
项目:droidddle    文件:FrescoUtils.java   
public static final void setShotUrl(DraweeView view, String url, String thumbnail/*, BaseControllerListener listener*/) {
        ImageRequest imageRequest = ImageRequestBuilder.newBuilderWithSource(Uri.parse(url))
//                .setResizeOptions(
//                        new ResizeOptions(300, 400))
                .setProgressiveRenderingEnabled(true)
                .build();
        ImageRequest lowRequest = null;
        if (!TextUtils.isEmpty(thumbnail)) {
            lowRequest = ImageRequest.fromUri(thumbnail);
        }
        DraweeController draweeController = Fresco.newDraweeControllerBuilder()
                .setImageRequest(imageRequest)
                .setLowResImageRequest(lowRequest)
                .setOldController(view.getController())
                .setAutoPlayAnimations(true)
//                .setControllerListener(listener)
                .build();
        view.setController(draweeController);
    }
项目:nono-android    文件:FrescoImageloadHelper.java   
public static void LoadImageFromURLAndCallBack(SimpleDraweeView destImageView , String URL,Context context,BaseBitmapDataSubscriber bbds)
{
    int w = destImageView.getWidth();
    int h  =destImageView.getHeight();
    if(w<1){
        w = destImageView.getLayoutParams().width;
    }
    if(h<1){
        h  =destImageView.getLayoutParams().height;
    }
    ImageRequest imageRequest =
            ImageRequestBuilder.newBuilderWithSource(Uri.parse(URL))
                    .setResizeOptions(new ResizeOptions(w,h))
                    .setProgressiveRenderingEnabled(true)
                    .build();
    ImagePipeline imagePipeline = Fresco.getImagePipeline();
    DataSource<CloseableReference<CloseableImage>> dataSource = imagePipeline.fetchDecodedImage(imageRequest, context);
    dataSource.subscribe(bbds, CallerThreadExecutor.getInstance());
    DraweeController draweeController = Fresco.newDraweeControllerBuilder()
            .setImageRequest(imageRequest)
            .setOldController(destImageView.getController())
            .setAutoPlayAnimations(true)
            .build();
    destImageView.setController(draweeController);
}
项目:nono-android    文件:FrescoImageloadHelper.java   
public static void LoadImageFromURIAndCallBack(SimpleDraweeView destImageView , Uri uri,Context context,BaseBitmapDataSubscriber bbds)
{
    int w = destImageView.getWidth();
    int h  =destImageView.getHeight();
    if(w<1){
        w = destImageView.getLayoutParams().width;
    }
    if(h<1){
        h  =destImageView.getLayoutParams().height;
    }
    ImageRequest imageRequest =
            ImageRequestBuilder.newBuilderWithSource(uri)
                    .setResizeOptions(new ResizeOptions(w,h))
                    .setProgressiveRenderingEnabled(true)
                    .build();
    ImagePipeline imagePipeline = Fresco.getImagePipeline();
    DataSource<CloseableReference<CloseableImage>> dataSource = imagePipeline.fetchDecodedImage(imageRequest, context);
    dataSource.subscribe(bbds, CallerThreadExecutor.getInstance());
    DraweeController draweeController = Fresco.newDraweeControllerBuilder()
            .setImageRequest(imageRequest)
            .setOldController(destImageView.getController())
            .setAutoPlayAnimations(true)
            .build();
    destImageView.setController(draweeController);
}
项目:Blockbuster    文件:MovieGalleryAdapter.java   
private void setupItemImage(SimpleDraweeView imageView, Uri imageUrl, boolean isVertical) {
        ImageRequest request = ImageRequestBuilder.newBuilderWithSource(imageUrl)
                .setProgressiveRenderingEnabled(true)
                .build();
        DraweeController controller = Fresco.newDraweeControllerBuilder()
                .setImageRequest(request)
                .setOldController(imageView.getController())
                .build();
        imageView.setController(controller);

       // imageView.setLayoutParams(new RelativeLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, (int) context.getResources().getDimension(R.dimen.poster_grid2_height)));

        final RelativeLayout.LayoutParams lp =
                    (RelativeLayout.LayoutParams) imageView.getLayoutParams();

//
            if (!isVertical) {
                lp.height = ViewGroup.LayoutParams.MATCH_PARENT;
                lp.width = (recyclerView.getMeasuredHeight()/3)*2/3;
            } else {
                lp.height = recyclerView.getMeasuredWidth()/2;
                lp.width = ViewGroup.LayoutParams.MATCH_PARENT;
            }
            imageView.setLayoutParams(lp);
    }
项目: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());
    }
项目:actor-platform    文件:CallBackgroundAvatarView.java   
public void bindRaw(String fileName) {
    if (bindedFile != null) {
        bindedFile.detach();
        bindedFile = null;
    }
    currentId = 0;

    ImageRequest request = ImageRequestBuilder.newBuilderWithSource(Uri.fromFile(new File(fileName)))
            .setAutoRotateEnabled(true)
            .build();
    PipelineDraweeController controller = (PipelineDraweeController) Fresco.newDraweeControllerBuilder()
            .setOldController(getController())
            .setImageRequest(request)
            .build();
    setController(controller);
}
项目:actor-platform    文件:AvatarView.java   
public void bindRaw(String fileName) {
    if (bindedFile != null) {
        bindedFile.detach();
        bindedFile = null;
    }
    currentId = 0;

    ImageRequest request = ImageRequestBuilder.newBuilderWithSource(Uri.fromFile(new File(fileName)))
            .setResizeOptions(new ResizeOptions(size, size))
            .setAutoRotateEnabled(true)
            .build();
    PipelineDraweeController controller = (PipelineDraweeController) Fresco.newDraweeControllerBuilder()
            .setOldController(getController())
            .setImageRequest(request)
            .build();
    setController(controller);
}
项目:TLint    文件:ImageAdapter.java   
@Override
public void onBindViewHolder(ViewHolder holder, int position) {
    Image image = images.get(position);
    holder.image = image;
    if (image == null) {
        return;
    }
    holder.ivCheck.setVisibility(View.VISIBLE);
    holder.ivCheck.setImageResource(selectedImages.contains(image) ? R.drawable.ap_gallery_checked
            : R.drawable.ap_gallery_normal);
    int width = 100, height = 100;
    ImageRequest request =
            ImageRequestBuilder.newBuilderWithSource(Uri.fromFile(new File(image.path)))
                    .setResizeOptions(new ResizeOptions(width, height))
                    .build();
    PipelineDraweeController controller =
            (PipelineDraweeController) Fresco.newDraweeControllerBuilder()
                    .setOldController(holder.ivPhoto.getController())
                    .setImageRequest(request)
                    .build();
    holder.ivPhoto.setController(controller);
}
项目:fresco    文件:FrescoHolder.java   
@Override
protected void onBind(String uriString) {
  Uri uri = Uri.parse(uriString);
  ImageRequestBuilder imageRequestBuilder =
      ImageRequestBuilder.newBuilderWithSource(uri);
  if (UriUtil.isNetworkUri(uri)) {
    imageRequestBuilder.setProgressiveRenderingEnabled(true);
  } else {
    imageRequestBuilder.setResizeOptions(new ResizeOptions(
        mImageView.getLayoutParams().width,
        mImageView.getLayoutParams().height));
  }
  DraweeController draweeController = Fresco.newDraweeControllerBuilder()
      .setImageRequest(imageRequestBuilder.build())
      .setOldController(mImageView.getController())
      .setControllerListener(mImageView.getListener())
      .setAutoPlayAnimations(true)
      .build();
  mImageView.setController(draweeController);
}
项目:fresco    文件:ImageFormatOverrideExample.java   
@Override
public void onViewCreated(View view, @Nullable Bundle savedInstanceState) {
  SimpleDraweeView simpleDraweeView = (SimpleDraweeView) view.findViewById(R.id.drawee_view);

  ImageDecodeOptions imageDecodeOptionsWithCustomDecoder = new ImageDecodeOptionsBuilder()
      .setCustomImageDecoder(CUSTOM_COLOR_DECODER)
      .build();

  AbstractDraweeController controller = Fresco.newDraweeControllerBuilder()
      .setImageRequest(
          ImageRequestBuilder.newBuilderWithResourceId(R.raw.custom_color1)
              .setImageDecodeOptions(imageDecodeOptionsWithCustomDecoder)
              .build())
      .build();
  simpleDraweeView.setController(controller);
}
项目:fresco    文件:MediaVariationsFragment.java   
private void loadThumb(
    SimpleDraweeView draweeView,
    Size size,
    ImageRequest.RequestLevel requestLevel) {
  ImageRequest request = ImageRequestBuilder.newBuilderWithSource(size.uri)
      .setMediaVariations(MediaVariations.newBuilderForMediaId(MEDIA_ID)
          .setForceRequestForSpecifiedUri(true)
          .build())
      .setLowestPermittedRequestLevel(requestLevel)
      .setResizeOptions(new ResizeOptions(draweeView.getWidth(), draweeView.getHeight()))
      .setCacheChoice(size.cacheChoice)
      .build();
  DraweeController controller = Fresco.newDraweeControllerBuilder()
      .setImageRequest(request)
      .setOldController(draweeView.getController())
      .build();
  draweeView.setController(controller);
}
项目:fresco    文件:MediaVariationsFragment.java   
private void loadMainImage() {
  // Request a non-existent image to force fallback to the variations
  Uri uri = Uri.parse(String.format(URI_TEMPLATE, "full", "jpg"));
  ImageRequest request = ImageRequestBuilder.newBuilderWithSource(uri)
      .setMediaVariations(getMediaVariationsForMode(mMode))
      .setResizeOptions(new ResizeOptions(
          mMainImageDraweeView.getWidth(),
          mMainImageDraweeView.getHeight()))
      .build();

  Log.i(
      TAG,
      request.getMediaVariations() == null ? "null" : request.getMediaVariations().toString());

  setDraweeControllerForRequest(request);
}
项目: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());
}