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


Java ImageRequestBuilder.setResizeOptions方法代码示例

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


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

示例3: getImageRequest

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

示例4: 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

示例5: 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

示例6: 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

示例7: 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

示例8: 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

示例9: displayImage

import com.facebook.imagepipeline.request.ImageRequestBuilder; //导入方法依赖的package包/类
@Override
public void displayImage(Context context,
                         String path,
                         FixImageView imageView,
                         Drawable defaultDrawable,
                         Bitmap.Config config,
                         boolean resize, boolean isGif,
                         int width,
                         int height,
                         int rotate) {
    init(context, defaultDrawable);

    imageView.setOnImageViewListener(new FixImageView.OnImageViewListener() {
        @Override
        public void onDetach() {
            draweeHolder.onDetach();
        }

        @Override
        public void onAttach() {
            draweeHolder.onAttach();
        }

        @Override
        public boolean verifyDrawable(Drawable dr) {
            return dr == draweeHolder.getHierarchy().getTopLevelDrawable();
        }

        @Override
        public void onDraw(Canvas canvas) {
            Drawable drawable = draweeHolder.getHierarchy().getTopLevelDrawable();
            if (drawable == null) {
                imageView.setImageDrawable(defaultDrawable);
            } else {
                imageView.setImageDrawable(drawable);
            }
        }

        @Override
        public boolean onTouchEvent(MotionEvent event) {
            return draweeHolder.onTouchEvent(event);
        }
    });
    Uri uri = new Uri.Builder()
            .scheme(UriUtil.LOCAL_FILE_SCHEME)
            .path(path)
            .build();
    ImageRequestBuilder builder = ImageRequestBuilder.newBuilderWithSource(uri)
            .setAutoRotateEnabled(true);
    if (resize) {
        builder.setResizeOptions(new ResizeOptions(width, height));
    }
    ImageRequest request = builder.build();
    DraweeController controller = Fresco.newDraweeControllerBuilder()
            .setOldController(draweeHolder.getController())
            .setImageRequest(request)
            .build();
    draweeHolder.setController(controller);
}
 
开发者ID:Loofer,项目名称:Watermark,代码行数:60,代码来源:FrescoImageLoader.java

示例10: 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

示例11: loadImageInternal

import com.facebook.imagepipeline.request.ImageRequestBuilder; //导入方法依赖的package包/类
/**
 * Internal helper method for load Bitmap.
 *
 * @param maxSize 0 or less than 0 if want original bitmap.
 */
@Override
public void loadImageInternal(
        final Uri uri,
        final int maxSize,
        final ImageLoaderUtils.ImageLoadListener listener) {

    if (uri == null) {
        listener.onFailed(-1);
        return;
    }

    ImageRequestBuilder builder = ImageRequestBuilder
            .newBuilderWithSource(uri)
            .setAutoRotateEnabled(true);
    if (maxSize > 0) {
        builder.setResizeOptions(new ResizeOptions(maxSize, maxSize));
    }

    ImagePipeline pipeline = Fresco.getImagePipeline();
    DataSource<CloseableReference<CloseableImage>> data =
            pipeline.fetchDecodedImage(builder.build(), null);

    Executor executor = new Executor() {
        @Override
        public void execute(@NonNull Runnable command) {
            ThreadManager.getInstance().postOnUIHandler(command);
        }
    };

    data.subscribe(new BaseBitmapDataSubscriber() {
        @Override
        protected void onNewResultImpl(Bitmap bitmap) {
            if (bitmap == null) {
                listener.onFailed(ImageLoaderUtils.ERROR_LOAD_EMPTY_IMAGE);
                return;
            }

            final int width = bitmap.getWidth();
            final int height = bitmap.getHeight();
            try {
                if (maxSize <= 0 || (width <= maxSize && height <= maxSize)) {
                    listener.onSuccess(uri, Bitmap.createBitmap(bitmap));
                } else {
                    JungleSize size = ImageUtils.getMaxScaleSize(
                            bitmap.getWidth(), bitmap.getHeight(), maxSize);
                    listener.onSuccess(uri, Bitmap.createScaledBitmap(
                            bitmap, size.getWidth(), size.getHeight(), true));
                }
            } catch (Throwable e) {
                e.printStackTrace();
                listener.onSuccess(uri, bitmap);
            }
        }

        @Override
        protected void onFailureImpl(
                DataSource<CloseableReference<CloseableImage>> dataSource) {
            listener.onFailed(ImageLoaderUtils.ERROR_LOAD_FAILED);
        }
    }, executor);
}
 
开发者ID:Android-Jungle,项目名称:android-jungle-framework,代码行数:67,代码来源:FrescoImageLoaderEngine.java

示例12: getImageRequest

import com.facebook.imagepipeline.request.ImageRequestBuilder; //导入方法依赖的package包/类
/**
 * Gets an image request with some commonly used parameters
 * such as the desired width and height.
 */
static ImageRequestBuilder getImageRequest(String url, int width, int height) {

    // Create a resize image request, allow full cache lookups.
    ImageRequestBuilder request = ImageRequestBuilder.newBuilderWithSource(Uri.parse(url))
        .setLowestPermittedRequestLevel(ImageRequest.RequestLevel.FULL_FETCH);

    boolean smallImage = !url.contains("gif") && width <= SMALL_IMAGE_MAX_SIZE && height <= SMALL_IMAGE_MAX_SIZE;

    // Use a smaller cache for everything else.
    request = request.setImageType(smallImage ? ImageRequest.ImageType.SMALL : ImageRequest.ImageType.DEFAULT);

    if (width > 0 && height > 0) {

        request = request.setResizeOptions(new ResizeOptions(width, height));
    }

    return request;
}
 
开发者ID:mrkcsc,项目名称:android-mg-bootstrap,代码行数:23,代码来源:MGImages.java


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