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