當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。