本文整理汇总了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);
}
示例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);
}
示例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();
}
示例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);
}
示例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);
}
示例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);
}
示例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()));
}
}
示例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);
}
示例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);
}
示例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);
}
示例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);
}
示例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;
}