当前位置: 首页>>代码示例>>Java>>正文


Java ImageRequestBuilder.newBuilderWithSource方法代码示例

本文整理汇总了Java中com.facebook.imagepipeline.request.ImageRequestBuilder.newBuilderWithSource方法的典型用法代码示例。如果您正苦于以下问题:Java ImageRequestBuilder.newBuilderWithSource方法的具体用法?Java ImageRequestBuilder.newBuilderWithSource怎么用?Java ImageRequestBuilder.newBuilderWithSource使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.facebook.imagepipeline.request.ImageRequestBuilder的用法示例。


在下文中一共展示了ImageRequestBuilder.newBuilderWithSource方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: onBind

import com.facebook.imagepipeline.request.ImageRequestBuilder; //导入方法依赖的package包/类
@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);
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:21,代码来源:FrescoHolder.java

示例2: displayImage

import com.facebook.imagepipeline.request.ImageRequestBuilder; //导入方法依赖的package包/类
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);
}
 
开发者ID:idisfkj,项目名称:Zoomable,代码行数:24,代码来源:MainActivity.java

示例3: into

import com.facebook.imagepipeline.request.ImageRequestBuilder; //导入方法依赖的package包/类
/**
 * 指定控件
 *
 * @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);
}
 
开发者ID:senierr,项目名称:ModuleFrame,代码行数:25,代码来源:FrescoUtil.java

示例4: loadBitmapFromUrl

import com.facebook.imagepipeline.request.ImageRequestBuilder; //导入方法依赖的package包/类
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());
}
 
开发者ID:PureDark,项目名称:H-Viewer,代码行数:20,代码来源:ImageLoader.java

示例5: loadResourceFromUrl

import com.facebook.imagepipeline.request.ImageRequestBuilder; //导入方法依赖的package包/类
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());
}
 
开发者ID:PureDark,项目名称:H-Viewer,代码行数:19,代码来源:ImageLoader.java

示例6: displayRaw

import com.facebook.imagepipeline.request.ImageRequestBuilder; //导入方法依赖的package包/类
@Override
public void displayRaw(@NonNull ImageView img, @NonNull String absPath, int width, int height,  IBoxingCallback callback) {
    absPath = "file://" + absPath;
    ImageRequestBuilder requestBuilder = ImageRequestBuilder.newBuilderWithSource(Uri.parse(absPath));
    if (width > 0 && height > 0) {
        requestBuilder.setResizeOptions(new ResizeOptions(width, height));
    }
    ImageRequest request = requestBuilder.build();
    loadImage(request, img, callback);
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:11,代码来源:BoxingFrescoLoader.java

示例7: disPlay

import com.facebook.imagepipeline.request.ImageRequestBuilder; //导入方法依赖的package包/类
/**
     * 自定义控件调用该方法显示
     * @param draweeView
     * @param uri
     * @param resizeOptions
     * @param defaultDrawable
     * @param scaleType
     */
    public void disPlay(DraweeView draweeView, Uri uri, String lowResUri, ResizeOptions resizeOptions, Drawable defaultDrawable, ScalingUtils.ScaleType scaleType, ControllerListener controllerListener) {
//        System.out.println(draweeView.hasHierarchy());
        if (!draweeView.hasHierarchy()) {
            setDefaultHierarchy(draweeView,defaultDrawable,scaleType);
        }
        ImageRequestBuilder imageRequestBuilder =
                ImageRequestBuilder.newBuilderWithSource(uri);
        if (UriUtil.isNetworkUri(uri)) {
            imageRequestBuilder.setProgressiveRenderingEnabled(true);
        }
        else {
            imageRequestBuilder.setLocalThumbnailPreviewsEnabled(true);
            imageRequestBuilder.setProgressiveRenderingEnabled(false);
            if ( resizeOptions != null ) {
                imageRequestBuilder.setResizeOptions(resizeOptions);
            }
        }
//        imageRequestBuilder.setAutoRotateEnabled(true);
//        imageRequestBuilder.setLowestPermittedRequestLevel(ImageRequest.RequestLevel.FULL_FETCH);
        DraweeController draweeController = Fresco.newDraweeControllerBuilder()
                .setImageRequest(imageRequestBuilder.build())
                .setOldController(draweeView.getController())
                .setLowResImageRequest(ImageRequest.fromUri(lowResUri))
                .setControllerListener(controllerListener)
                .build();
        draweeView.setController(draweeController);
    }
 
开发者ID:ebridfighter,项目名称:GongXianSheng,代码行数:36,代码来源:FrecoFactory.java

示例8: bindImage

import com.facebook.imagepipeline.request.ImageRequestBuilder; //导入方法依赖的package包/类
@Override
public void bindImage(ImageView photoImageView, Uri uri, int width, int height) {
    DraweeView draweeView = (DraweeView) photoImageView;
    final ImageRequestBuilder requestBuilder = ImageRequestBuilder.newBuilderWithSource(uri);
    if (width > 0 && height > 0) {
        requestBuilder.setResizeOptions(new ResizeOptions(width, height));
    }
    ImageRequest imageRequest = requestBuilder.build();
    DraweeController controller = Fresco.newDraweeControllerBuilder()
            .setOldController(draweeView.getController())
            .setImageRequest(imageRequest).build();
    draweeView.setController(controller);
}
 
开发者ID:nowandfurure,项目名称:richeditor,代码行数:14,代码来源:FrescoImageLoader.java

示例9: draw

import com.facebook.imagepipeline.request.ImageRequestBuilder; //导入方法依赖的package包/类
@Override
public void draw(
    Canvas canvas,
    CharSequence text,
    int start,
    int end,
    float x,
    int top,
    int y,
    int bottom,
    Paint paint) {
  if (mDrawable == null) {
    ImageRequestBuilder imageRequestBuilder = ImageRequestBuilder.newBuilderWithSource(mUri);
    ImageRequest imageRequest = ReactNetworkImageRequest.fromBuilderWithHeaders(imageRequestBuilder, mHeaders);

    DraweeController draweeController = mDraweeControllerBuilder
        .reset()
        .setOldController(mDraweeHolder.getController())
        .setCallerContext(mCallerContext)
        .setImageRequest(imageRequest)
        .build();
    mDraweeHolder.setController(draweeController);

    mDrawable = mDraweeHolder.getTopLevelDrawable();
    mDrawable.setBounds(0, 0, mWidth, mHeight);
    mDrawable.setCallback(mTextView);
  }

  // NOTE: This drawing code is copied from DynamicDrawableSpan

  canvas.save();

  // Align to baseline by default
  int transY = y - mDrawable.getBounds().bottom;

  canvas.translate(x, transY);
  mDrawable.draw(canvas);
  canvas.restore();
}
 
开发者ID:qq565999484,项目名称:RNLearn_Project1,代码行数:40,代码来源:FrescoBasedReactTextInlineImageSpan.java

示例10: loadImageURI

import com.facebook.imagepipeline.request.ImageRequestBuilder; //导入方法依赖的package包/类
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()));
    }
}
 
开发者ID:ImKarl,项目名称:JianshuApp,代码行数:36,代码来源:UniversalDraweeView.java

示例11: onSuccess

import com.facebook.imagepipeline.request.ImageRequestBuilder; //导入方法依赖的package包/类
public void onSuccess(String result) {
    ImageRequestBuilder imageRequestBuilder = ImageRequestBuilder.newBuilderWithSource(Uri.parse(result));
    if(mConfig.isResize()){
        imageRequestBuilder.setResizeOptions(ResizeOptions.forDimensions(mConfig.getWidth(),mConfig.getHeight()));
    }
    DraweeController controller = Fresco.newDraweeControllerBuilder()
            .setImageRequest(imageRequestBuilder.build())
            .setOldController(mImage.getController())
            .build();

    mImage.setController(controller);
}
 
开发者ID:rRemix,项目名称:APlayer,代码行数:13,代码来源:LibraryUriRequest.java

示例12: prefetchToDiskCache

import com.facebook.imagepipeline.request.ImageRequestBuilder; //导入方法依赖的package包/类
@Override
public void prefetchToDiskCache(Uri uri) {
    ImageRequestBuilder builder = ImageRequestBuilder
            .newBuilderWithSource(uri);
    ImagePipeline pipeline = Fresco.getImagePipeline();
    pipeline.prefetchToDiskCache(builder.build(), null);
}
 
开发者ID:Android-Jungle,项目名称:android-jungle-framework,代码行数:8,代码来源:FrescoImageLoaderEngine.java

示例13: prefetchToMemoryCache

import com.facebook.imagepipeline.request.ImageRequestBuilder; //导入方法依赖的package包/类
@Override
public void prefetchToMemoryCache(Uri uri) {
    ImageRequestBuilder builder = ImageRequestBuilder
            .newBuilderWithSource(uri);
    ImagePipeline pipeline = Fresco.getImagePipeline();
    pipeline.prefetchToBitmapCache(builder.build(), null);
}
 
开发者ID:Android-Jungle,项目名称:android-jungle-framework,代码行数:8,代码来源:FrescoImageLoaderEngine.java

示例14: buildRequest

import com.facebook.imagepipeline.request.ImageRequestBuilder; //导入方法依赖的package包/类
private ImageRequest buildRequest(ImageConfig config) {
    Uri uri = buildUriByType(config);

    ImageRequestBuilder builder =   ImageRequestBuilder.newBuilderWithSource(uri);
    Postprocessor postprocessor=null;


    ResizeOptions resizeOptions = getResizeOption(config);


    builder.setPostprocessor(postprocessor)
            .setResizeOptions(resizeOptions)//缩放,在解码前修改内存中的图片大小, 配合Downsampling可以处理所有图片,否则只能处理jpg,
            // 开启Downsampling:在初始化时设置.setDownsampleEnabled(true)
            .setAutoRotateEnabled(true);




    return builder.build();
}
 
开发者ID:BaoBaoJianqiang,项目名称:CustomListView,代码行数:21,代码来源:FrescoImageLoaderStrategy.java

示例15: fetchImage

import com.facebook.imagepipeline.request.ImageRequestBuilder; //导入方法依赖的package包/类
/**
 * @param frescoPlusView The draweeView is to display the bitmap
 * @param uri         The source uri
 * @param callback    Listening to the success or failure
 */
private void fetchImage(FrescoPlusView frescoPlusView, Uri uri, FPFetchCallback<ImageInfo> callback) {
    GenericDraweeHierarchyBuilder hierarchyBuilder = new GenericDraweeHierarchyBuilder(null);
    hierarchyBuilder.setFadeDuration(fadeDuration);
    hierarchyBuilder.setRoundingParams(RoundingParams.fromCornersRadius(radius));
    hierarchyBuilder.setActualImageScaleType(scaleType);
    if (defaultDrawable != null)
        hierarchyBuilder.setPlaceholderImage(defaultDrawable, scaleType);
    if (pressedDrawable != null)
        hierarchyBuilder.setPressedStateOverlay(pressedDrawable);
    if (retryDrawable != null)
        hierarchyBuilder.setRetryImage(retryDrawable);
    if (overlayDrawable != null)
        hierarchyBuilder.setOverlay(overlayDrawable);
    if (failureDrawable != null)
        hierarchyBuilder.setFailureImage(failureDrawable, scaleType);
    if (progressDrawable != null)
        hierarchyBuilder.setProgressBarImage(progressDrawable);
    GenericDraweeHierarchy hierarchy = hierarchyBuilder.build();

    ImageRequestBuilder requestBuilder = ImageRequestBuilder.newBuilderWithSource(uri);
    requestBuilder.setLowestPermittedRequestLevel(requestLevel);
    requestBuilder.setAutoRotateEnabled(autoRotateEnabled);
    if (postprocessor != null)
        requestBuilder.setPostprocessor(postprocessor);
    Priority priority = requestPriority == FrescoPriority.HIGH ? Priority.HIGH : Priority.MEDIUM;
    requestBuilder.setRequestPriority(priority);
    if (resizeWidth > 0 && resizeHeight > 0)
        requestBuilder.setResizeOptions(new ResizeOptions(resizeWidth, resizeHeight));
    ImageRequest imageRequest = requestBuilder.build();

    DraweeController draweeController = FrescoPlusCore.newDraweeControllerBuilder()
            .setOldController(frescoPlusView.getController())
            .setAutoPlayAnimations(true)
            .setRetainImageOnFailure(true)
            .setTapToRetryEnabled(true)
            .setImageRequest(imageRequest)
            .setControllerListener(FetchImageControllerListenerSupplier.newInstance(callback))
            .build();
    frescoPlusView.setHierarchy(hierarchy);
    frescoPlusView.setController(draweeController);
}
 
开发者ID:Sunzxyong,项目名称:FrescoPlus,代码行数:47,代码来源:FrescoPlusFetcher.java


注:本文中的com.facebook.imagepipeline.request.ImageRequestBuilder.newBuilderWithSource方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。