本文整理汇总了Java中com.facebook.imagepipeline.request.ImageRequestBuilder类的典型用法代码示例。如果您正苦于以下问题:Java ImageRequestBuilder类的具体用法?Java ImageRequestBuilder怎么用?Java ImageRequestBuilder使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
ImageRequestBuilder类属于com.facebook.imagepipeline.request包,在下文中一共展示了ImageRequestBuilder类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: onViewCreated
import com.facebook.imagepipeline.request.ImageRequestBuilder; //导入依赖的package包/类
@Override
public void onViewCreated(View view, @Nullable Bundle savedInstanceState) {
SimpleDraweeView simpleDraweeView = (SimpleDraweeView) view.findViewById(R.id.drawee_view);
ImageDecodeOptions imageDecodeOptionsWithCustomDecoder = new ImageDecodeOptionsBuilder()
.setCustomImageDecoder(CUSTOM_COLOR_DECODER)
.build();
AbstractDraweeController controller = Fresco.newDraweeControllerBuilder()
.setImageRequest(
ImageRequestBuilder.newBuilderWithResourceId(R.raw.custom_color1)
.setImageDecodeOptions(imageDecodeOptionsWithCustomDecoder)
.build())
.build();
simpleDraweeView.setController(controller);
}
示例2: 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);
}
示例3: loadThumb
import com.facebook.imagepipeline.request.ImageRequestBuilder; //导入依赖的package包/类
private void loadThumb(
SimpleDraweeView draweeView,
Size size,
ImageRequest.RequestLevel requestLevel) {
ImageRequest request = ImageRequestBuilder.newBuilderWithSource(size.uri)
.setMediaVariations(MediaVariations.newBuilderForMediaId(MEDIA_ID)
.setForceRequestForSpecifiedUri(true)
.build())
.setLowestPermittedRequestLevel(requestLevel)
.setResizeOptions(new ResizeOptions(draweeView.getWidth(), draweeView.getHeight()))
.setCacheChoice(size.cacheChoice)
.build();
DraweeController controller = Fresco.newDraweeControllerBuilder()
.setImageRequest(request)
.setOldController(draweeView.getController())
.build();
draweeView.setController(controller);
}
示例4: loadMainImage
import com.facebook.imagepipeline.request.ImageRequestBuilder; //导入依赖的package包/类
private void loadMainImage() {
// Request a non-existent image to force fallback to the variations
Uri uri = Uri.parse(String.format(URI_TEMPLATE, "full", "jpg"));
ImageRequest request = ImageRequestBuilder.newBuilderWithSource(uri)
.setMediaVariations(getMediaVariationsForMode(mMode))
.setResizeOptions(new ResizeOptions(
mMainImageDraweeView.getWidth(),
mMainImageDraweeView.getHeight()))
.build();
Log.i(
TAG,
request.getMediaVariations() == null ? "null" : request.getMediaVariations().toString());
setDraweeControllerForRequest(request);
}
示例5: bind
import com.facebook.imagepipeline.request.ImageRequestBuilder; //导入依赖的package包/类
/**
* @param uri The Uri to show into the DraweeView for this Holder
*/
public void bind(Uri uri) {
mDraweeView.initInstrumentation(uri.toString(), mPerfListener);
ImageRequestBuilder imageRequestBuilder = ImageRequestBuilder
.newBuilderWithSource(uri)
.setResizeOptions(
new ResizeOptions(
mDraweeView.getLayoutParams().width,
mDraweeView.getLayoutParams().height));
PipelineUtil.addOptionalFeatures(imageRequestBuilder, mConfig);
// Create the Builder
PipelineDraweeControllerBuilder builder = Fresco.newDraweeControllerBuilder()
.setImageRequest(imageRequestBuilder.build());
if (mConfig.reuseOldController) {
builder.setOldController(mDraweeView.getController());
}
mDraweeView.setListener(builder);
mDraweeView.setController(builder.build());
}
示例6: addOptionalFeatures
import com.facebook.imagepipeline.request.ImageRequestBuilder; //导入依赖的package包/类
/**
* Utility method which adds optional configuration to ImageRequest
*
* @param imageRequestBuilder The Builder for ImageRequest
* @param config The Config
*/
public static void addOptionalFeatures(ImageRequestBuilder imageRequestBuilder, Config config) {
if (config.usePostprocessor) {
final Postprocessor postprocessor;
switch (config.postprocessorType) {
case "use_slow_postprocessor":
postprocessor = DelayPostprocessor.getMediumPostprocessor();
break;
case "use_fast_postprocessor":
postprocessor = DelayPostprocessor.getFastPostprocessor();
break;
default:
postprocessor = DelayPostprocessor.getMediumPostprocessor();
}
imageRequestBuilder.setPostprocessor(postprocessor);
}
if (config.rotateUsingMetaData) {
imageRequestBuilder.setRotationOptions(RotationOptions.autoRotateAtRenderTime());
} else {
imageRequestBuilder
.setRotationOptions(RotationOptions.forceRotation(config.forcedRotationAngle));
}
}
示例7: 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);
}
示例8: layoutChildrenView
import com.facebook.imagepipeline.request.ImageRequestBuilder; //导入依赖的package包/类
private void layoutChildrenView() {
int childrenCount = getChildCount();
for (int i = 0; i < childrenCount; i++) {
ViewGroup childImageLayout = (ViewGroup) getChildAt(i);
SimpleDraweeView childImageView = (SimpleDraweeView) childImageLayout.getChildAt(0);
if (mOnItemClickListener != null) {
final int finalI = i;
childImageLayout.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
mOnItemClickListener.OnItemClick(finalI);
}
});
}
ImageRequest request = ImageRequestBuilder.newBuilderWithSource(Uri.parse(mImageUrls.get(i)))
.setProgressiveRenderingEnabled(true)
.setResizeOptions(new ResizeOptions(mItemWidth, mItemWidth))
.build();
DraweeController controller = Fresco.newDraweeControllerBuilder()
.setImageRequest(request)
.setOldController(childImageView.getController())
.build();
childImageView.setController(controller);
int[] position = findPosition(i);
int itemHeight = mItemWidth;
int left = (int) (mItemWidth + mHorizontalSpace) * position[1];
int top = (int) (itemHeight + mVerticalSpace) * position[0];
int right = left + mItemWidth;
int bottom = top + itemHeight;
childImageLayout.layout(left, top, right, bottom);
}
}
示例9: refreshImageChild
import com.facebook.imagepipeline.request.ImageRequestBuilder; //导入依赖的package包/类
private void refreshImageChild() {
int childrenCount = getChildCount();
if (childrenCount > 0) {
for (int i = 0; i < childrenCount; i++) {
ViewGroup childImageLayout = (ViewGroup) getChildAt(i);
SimpleDraweeView childImageView = (SimpleDraweeView) childImageLayout.getChildAt(0);
if (mOnItemClickListener != null) {
final int finalI = i;
childImageLayout.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
mOnItemClickListener.OnItemClick(finalI);
}
});
}
ImageRequest request = ImageRequestBuilder.newBuilderWithSource(Uri.parse(mImageUrls.get(i)))
.setResizeOptions(new ResizeOptions(mItemWidth, mItemWidth))
.build();
DraweeController controller = Fresco.newDraweeControllerBuilder()
.setImageRequest(request)
.setOldController(childImageView.getController())
.build();
childImageView.setController(controller);
}
}
}
示例10: display
import com.facebook.imagepipeline.request.ImageRequestBuilder; //导入依赖的package包/类
public void display(SimpleDraweeView view, String url, Postprocessor postprocessor) {
if (!TextUtils.isEmpty(url)) {
Uri uri;
if (URLUtil.isNetworkUrl(url)) {
uri = Uri.parse(url);
} else {
uri = Uri.fromFile(new File(url));
}
ImageRequest request = ImageRequestBuilder
.newBuilderWithSource(uri)
.setPostprocessor(postprocessor)
.setProgressiveRenderingEnabled(true)
//.setResizeOptions(new ResizeOptions(100, 100))
.setLocalThumbnailPreviewsEnabled(true)
.setRotationOptions(RotationOptions.autoRotateAtRenderTime())
.build();
controller = Fresco.newDraweeControllerBuilder()
.setImageRequest(request)
.setOldController(view.getController())
.build();
view.setController(controller);
}
}
示例11: setBlurFrescoController
import com.facebook.imagepipeline.request.ImageRequestBuilder; //导入依赖的package包/类
public static void setBlurFrescoController(SimpleDraweeView simpleDraweeView, String url, int iterations, int blurRadius) {
try {
Uri uri = Uri.parse(url);
ImageRequest request = ImageRequestBuilder.newBuilderWithSource(uri)
.setPostprocessor(new IterativeBoxBlurPostProcessor(iterations, blurRadius))
.build();
DraweeController controller = Fresco.newDraweeControllerBuilder()
.setOldController(simpleDraweeView.getController())
.setImageRequest(request)
.build();
simpleDraweeView.setController(controller);
} catch (Exception e) {
e.printStackTrace();
}
}
示例12: setImageSmall
import com.facebook.imagepipeline.request.ImageRequestBuilder; //导入依赖的package包/类
public static void setImageSmall(String url,
SimpleDraweeView simpleDraweeView,
int width,
int height,
SquareRelativeLayout relativeLayout, boolean playGif) {
Uri uri = Uri.parse(url);
ImageRequest request = ImageRequestBuilder
.newBuilderWithSource(uri)
.setRotationOptions(RotationOptions.autoRotate())
.setResizeOptions(new ResizeOptions(width, height))
.setLowestPermittedRequestLevel(ImageRequest.RequestLevel.FULL_FETCH)
.build();
DraweeController controller = Fresco.newDraweeControllerBuilder()
.setTapToRetryEnabled(true)
.setImageRequest(request)
.setAutoPlayAnimations(playGif)
.setOldController(simpleDraweeView.getController())
.build();
relativeLayout.setLayoutParams(new RelativeLayout.LayoutParams(width - 5, height));
simpleDraweeView.setController(controller);
}
示例13: bindView
import com.facebook.imagepipeline.request.ImageRequestBuilder; //导入依赖的package包/类
@Override
public void bindView(TumblrAccount account) {
this.account = account;
if (account.isUsing()) {
checkedView.setVisibility(View.VISIBLE);
} else {
checkedView.setVisibility(View.GONE);
}
if (!TextUtils.isEmpty(account.getName())) {
nameView.setText(account.getName());
FrescoUtils.setTumblrAvatarUri(avatarView, account.getName(), 128);
} else {
nameView.setText(getResources().getString(R.string.settings_accounts_title,
getAdapterPosition() + 1));
ImageRequest imageRequest = ImageRequestBuilder
.newBuilderWithResourceId(R.mipmap.ic_account_default).build();
avatarView.setImageURI(imageRequest.getSourceUri());
}
keyView.setText(account.getApiKey());
}
示例14: 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);
}
示例15: setupItemImage
import com.facebook.imagepipeline.request.ImageRequestBuilder; //导入依赖的package包/类
private void setupItemImage(SimpleDraweeView imageView, Uri imageUrl, boolean isVertical) {
ImageRequest request = ImageRequestBuilder.newBuilderWithSource(imageUrl)
.setProgressiveRenderingEnabled(true)
.build();
DraweeController controller = Fresco.newDraweeControllerBuilder()
.setImageRequest(request)
.setOldController(imageView.getController())
.build();
imageView.setController(controller);
// imageView.setLayoutParams(new RelativeLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, (int) context.getResources().getDimension(R.dimen.poster_grid2_height)));
final RelativeLayout.LayoutParams lp =
(RelativeLayout.LayoutParams) imageView.getLayoutParams();
//
if (!isVertical) {
lp.height = ViewGroup.LayoutParams.MATCH_PARENT;
lp.width = (recyclerView.getMeasuredHeight()/3)*2/3;
} else {
lp.height = recyclerView.getMeasuredWidth()/2;
lp.width = ViewGroup.LayoutParams.MATCH_PARENT;
}
imageView.setLayoutParams(lp);
}