com.facebook.drawee.backends.pipeline.PipelineDraweeControllerBuilder Java Examples
The following examples show how to use
com.facebook.drawee.backends.pipeline.PipelineDraweeControllerBuilder.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: DraweeViewHolder.java From fresco with MIT License | 6 votes |
/** @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()); }
Example #2
Source File: ImageFormatGifFragment.java From fresco with MIT License | 6 votes |
private void setAnimationUri(Uri uri) { final PipelineDraweeControllerBuilder controllerBuilder = Fresco.newDraweeControllerBuilder() .setAutoPlayAnimations(true) .setOldController(mSimpleDraweeView.getController()); final ImageDecodeOptionsBuilder optionsBuilder = ImageDecodeOptions.newBuilder().setMaxDimensionPx(4000); if (mGifDecoder != null) { optionsBuilder.setCustomImageDecoder(mGifDecoder); } controllerBuilder.setImageRequest( ImageRequestBuilder.newBuilderWithSource(uri) .setImageDecodeOptions(optionsBuilder.build()) .build()); mSimpleDraweeView.setController(controllerBuilder.build()); }
Example #3
Source File: FrescoImageLoader.java From FimiX8-RE with MIT License | 6 votes |
public static void display(SimpleDraweeView view, String uri, int width, int height, ControllerListener listener) { if (uri != null) { PipelineDraweeControllerBuilder controller = Fresco.newDraweeControllerBuilder(); controller.setOldController(view.getController()); controller.setAutoPlayAnimations(true); ImageRequestBuilder imageRequest = ImageRequestBuilder.newBuilderWithSource(Uri.parse(uri)).setCacheChoice(CacheChoice.SMALL).setLocalThumbnailPreviewsEnabled(true); imageRequest.setProgressiveRenderingEnabled(true); Log.d("Good", uri); if (width > 0 && height > 0) { imageRequest.setResizeOptions(new ResizeOptions(width, height)); } controller.setImageRequest(imageRequest.build()); controller.setControllerListener(listener); view.setController(controller.build()); } }
Example #4
Source File: FacebookImageUtil.java From imsdk-android with MIT License | 6 votes |
public static void loadWithCache(String url, final SimpleDraweeView target,ImageRequest.CacheChoice type,boolean playAnim) { if (target == null) return; Uri uri = Uri.parse(url); ImageRequestBuilder builder = ImageRequestBuilder.newBuilderWithSource(uri); ImageRequest request = builder .setCacheChoice(type) .build(); final PipelineDraweeControllerBuilder pipelineDraweeControllerBuilder = Fresco.newDraweeControllerBuilder() .setImageRequest(request) .setAutoPlayAnimations(playAnim) .setOldController(target.getController()); handler.post(new Runnable() { @Override public void run() { DraweeController controller = pipelineDraweeControllerBuilder.build(); target.setController(controller); } }); }
Example #5
Source File: ImageViewerAdapter.java From photo-viewer with Apache License 2.0 | 6 votes |
private void setController(String url, ReadableMap headers) { PipelineDraweeControllerBuilder controllerBuilder = Fresco.newDraweeControllerBuilder(); // controllerBuilder.setUri(url); controllerBuilder.setOldController(drawee.getController()); controllerBuilder.setControllerListener(getDraweeControllerListener(drawee)); controllerBuilder.setAutoPlayAnimations(true); if (imageRequestBuilder != null) { imageRequestBuilder.setSource(Uri.parse(url)); controllerBuilder.setImageRequest(imageRequestBuilder.build()); } // support load local image just like React Native do ImageSource imageSource = new ImageSource(getContext(), url); ImageRequestBuilder imageRequestBuilder1 = ImageRequestBuilder.newBuilderWithSource(imageSource.getUri()); // support headers ImageRequest imageRequest = ReactNetworkImageRequest.fromBuilderWithHeaders(imageRequestBuilder1, headers); controllerBuilder.setImageRequest(imageRequest); drawee.setController(controllerBuilder.build()); }
Example #6
Source File: ViewPagerActivity.java From PhotoDraweeView with Apache License 2.0 | 6 votes |
@Override public Object instantiateItem(ViewGroup viewGroup, int position) { final PhotoDraweeView photoDraweeView = new PhotoDraweeView(viewGroup.getContext()); PipelineDraweeControllerBuilder controller = Fresco.newDraweeControllerBuilder(); controller.setUri(Uri.parse("res:///" + mDrawables[position])); controller.setOldController(photoDraweeView.getController()); controller.setControllerListener(new BaseControllerListener<ImageInfo>() { @Override public void onFinalImageSet(String id, ImageInfo imageInfo, Animatable animatable) { super.onFinalImageSet(id, imageInfo, animatable); if (imageInfo == null) { return; } photoDraweeView.update(imageInfo.getWidth(), imageInfo.getHeight()); } }); photoDraweeView.setController(controller.build()); try { viewGroup.addView(photoDraweeView, ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT); } catch (Exception e) { e.printStackTrace(); } return photoDraweeView; }
Example #7
Source File: GalleryActivity.java From phphub-android with Apache License 2.0 | 6 votes |
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); String imageUrl = getIntent().getStringExtra(IMAGE_URL); if (!TextUtils.isEmpty(imageUrl)) { PipelineDraweeControllerBuilder builder = Fresco.newDraweeControllerBuilder(); builder.setUri(Uri.parse(imageUrl)); builder.setOldController(photoView.getController()); builder.setControllerListener(new BaseControllerListener<ImageInfo>() { @Override public void onFinalImageSet(String id, ImageInfo imageInfo, Animatable animatable) { super.onFinalImageSet(id, imageInfo, animatable); if (imageInfo == null || photoView == null) { return; } photoView.update(imageInfo.getWidth(), imageInfo.getHeight()); } }); photoView.setController(builder.build()); } }
Example #8
Source File: PhotoShowActivity.java From Elephant with Apache License 2.0 | 6 votes |
@Override public void initLoad() { super.initLoad(); if (!TextUtils.isEmpty(mImageUrl)) { PipelineDraweeControllerBuilder controller = Fresco.newDraweeControllerBuilder(); controller.setUri(mImageUrl); controller.setOldController(mPhotoIv.getController()); controller.setControllerListener(new BaseControllerListener<ImageInfo>() { @Override public void onFinalImageSet(String id, ImageInfo imageInfo, Animatable animatable) { super.onFinalImageSet(id, imageInfo, animatable); if (imageInfo == null || mPhotoIv == null) { return; } mPhotoIv.update(imageInfo.getWidth(), imageInfo.getHeight()); } }); mPhotoIv.setController(controller.build()); } }
Example #9
Source File: FrescoUtils.java From SprintNBA with Apache License 2.0 | 5 votes |
public static PipelineDraweeControllerBuilder getPreController(String url, final PhotoDraweeView draweeView) { ImageRequest request = ImageRequestBuilder.newBuilderWithSource(Uri.parse(url)) .setProgressiveRenderingEnabled(true) .build(); PipelineDraweeControllerBuilder controller = Fresco.newDraweeControllerBuilder(); controller.setImageRequest(request); controller.setOldController(draweeView.getController()); controller.setAutoPlayAnimations(true); return controller; }
Example #10
Source File: DraweeViewListAdapter.java From fresco with MIT License | 5 votes |
@Override public View getView(int position, View convertView, ViewGroup parent) { InstrumentedDraweeView draweeView; if (convertView == null) { final Context context = parent.getContext(); GenericDraweeHierarchy gdh = DraweeUtil.createDraweeHierarchy(context, mConfig); draweeView = new InstrumentedDraweeView(context, gdh, mConfig); SizeUtil.setConfiguredSize(parent, draweeView, mConfig); draweeView.setPadding(mPaddingPx, mPaddingPx, mPaddingPx, mPaddingPx); } else { draweeView = (InstrumentedDraweeView) convertView; } final Uri uri = getItem(position); draweeView.initInstrumentation(uri.toString(), mPerfListener); ImageRequestBuilder imageRequestBuilder = ImageRequestBuilder.newBuilderWithSource(uri) .setResizeOptions( new ResizeOptions( draweeView.getLayoutParams().width, draweeView.getLayoutParams().height)); PipelineUtil.addOptionalFeatures(imageRequestBuilder, mConfig); // Create the Builder PipelineDraweeControllerBuilder builder = Fresco.newDraweeControllerBuilder().setImageRequest(imageRequestBuilder.build()); if (mConfig.reuseOldController) { builder.setOldController(draweeView.getController()); } if (mConfig.instrumentationEnabled) { draweeView.setListener(builder); } draweeView.setController(builder.build()); return draweeView; }
Example #11
Source File: ImagePerfMonitor.java From fresco with MIT License | 5 votes |
public void updateImageRequestData( AbstractDraweeControllerBuilder< PipelineDraweeControllerBuilder, ImageRequest, CloseableReference<CloseableImage>, ImageInfo> pipelineDraweeControllerBuilder) { mImagePerfState.setControllerImageRequests( pipelineDraweeControllerBuilder.getImageRequest(), pipelineDraweeControllerBuilder.getLowResImageRequest(), pipelineDraweeControllerBuilder.getFirstAvailableImageRequests()); }
Example #12
Source File: ImageFragment.java From TLint with Apache License 2.0 | 5 votes |
@Override public void initData() { showContent(true); ImageRequest request = ImageRequestBuilder.newBuilderWithSource(Uri.parse(url)) .setProgressiveRenderingEnabled(true) .build(); GenericDraweeHierarchy hierarchy = new GenericDraweeHierarchyBuilder(getResources()).setProgressBarImage( new ImageLoadProgressBar(new ImageLoadProgressBar.OnLevelChangeListener() { @Override public void onChange(int level) { if (level > 100 && progress.getVisibility() == View.VISIBLE) { progress.setVisibility(View.GONE); } } }, ResourceUtil.getThemeColor(getActivity()))).build(); hierarchy.setActualImageScaleType(ScalingUtils.ScaleType.FIT_CENTER); PipelineDraweeControllerBuilder controller = Fresco.newDraweeControllerBuilder(); controller.setControllerListener(listener); controller.setImageRequest(request); controller.setOldController(image.getController()); controller.setAutoPlayAnimations(true); image.setHierarchy(hierarchy); image.setController(controller.build()); }
Example #13
Source File: PostItemAnimatedView.java From redgram-for-reddit with GNU General Public License v3.0 | 5 votes |
private DraweeController getDraweeController(PostItem item) { Uri thumbnailUri = Uri.parse(item.getThumbnail()); ImageRequest thumbnail = ImageRequestBuilder.newBuilderWithSource(thumbnailUri) .build(); PipelineDraweeControllerBuilder builder = Fresco.newDraweeControllerBuilder() .setImageRequest(thumbnail) .setOldController(thumbnailView.getController()); return builder.build(); }
Example #14
Source File: PostItemGalleryView.java From redgram-for-reddit with GNU General Public License v3.0 | 5 votes |
private DraweeController getDraweeController(PostItem item) { Uri thumbnailUri = Uri.parse(item.getThumbnail()); ImageRequest thumbnail = ImageRequestBuilder.newBuilderWithSource(thumbnailUri) .build(); PipelineDraweeControllerBuilder builder = Fresco.newDraweeControllerBuilder() .setImageRequest(thumbnail) .setOldController(thumbnailView.getController()); return builder.build(); }
Example #15
Source File: UniversalDraweeView.java From JianshuApp with GNU General Public License v3.0 | 5 votes |
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())); } }
Example #16
Source File: ImagePreFragment.java From SprintNBA with Apache License 2.0 | 5 votes |
private void initImage() { PipelineDraweeControllerBuilder controller = FrescoUtils.getPreController(url, pdvImage); controller.setControllerListener(listener); final GenericDraweeHierarchy hierarchy = new GenericDraweeHierarchyBuilder(getResources()) .setProgressBarImage(new ImageLoadProgressBar(new ImageLoadProgressBar.OnLevelChangeListener() { @Override public void onChange(int level) { if (level >= 100) { hideLoadingDialog(); } } }, Color.parseColor("#90CCCCCC"))).build(); hierarchy.setActualImageScaleType(ScalingUtils.ScaleType.FIT_CENTER); pdvImage.setHierarchy(hierarchy); pdvImage.setController(controller.build()); pdvImage.setOnPhotoTapListener(new OnPhotoTapListener() { @Override public void onPhotoTap(View view, float x, float y) { if (mActivity != null) mActivity.finish(); } }); pdvImage.setOnLongClickListener(new View.OnLongClickListener() { @Override public boolean onLongClick(View v) { return true; } }); }
Example #17
Source File: FrescoUtils.java From FimiX8-RE with MIT License | 5 votes |
public static void displayPhoto(SimpleDraweeView mSimpleDraweeView, String path, int width, int height) { if (!TextUtils.isEmpty(path)) { PipelineDraweeControllerBuilder mPipelineDraweeControllerBuilder = Fresco.newDraweeControllerBuilder(); ImageRequestBuilder mImageRequestBuilder = ImageRequestBuilder.newBuilderWithSource(Uri.parse(path)); mImageRequestBuilder.setResizeOptions(new ResizeOptions(width, height)); mPipelineDraweeControllerBuilder.setOldController(mSimpleDraweeView.getController()); mPipelineDraweeControllerBuilder.setImageRequest(mImageRequestBuilder.build()); mSimpleDraweeView.setController(mPipelineDraweeControllerBuilder.build()); } }
Example #18
Source File: GifImageView.java From JD-Test with Apache License 2.0 | 5 votes |
public void setImageUriAndAutoPlay(String uri){ PipelineDraweeControllerBuilder builder = Fresco.newDraweeControllerBuilder() .setAutoPlayAnimations(true); if(!TextUtils.isEmpty(uri)){ builder.setUri(Uri.parse(uri)); } setController(builder.build()); }
Example #19
Source File: FrescoLoader.java From ImageLoader with Apache License 2.0 | 5 votes |
private void requestForSimpleDraweeView(SimpleDraweeView target, SingleConfig config) { // 数据-model ImageRequest request = buildRequest(config); //view setDraweeHierarchyForDraweeView(config); //controller PipelineDraweeControllerBuilder controller = buildPipelineDraweeController(config,request); controller.setOldController(target.getController()); target.setController(controller.build()); }
Example #20
Source File: UETFresco.java From UETool with MIT License | 5 votes |
private PipelineDraweeControllerBuilder getFrescoControllerBuilder(DraweeView draweeView) { try { PipelineDraweeController controller = (PipelineDraweeController) draweeView.getController(); Field mDataSourceSupplierFiled = PipelineDraweeController.class.getDeclaredField("mDataSourceSupplier"); mDataSourceSupplierFiled.setAccessible(true); Supplier supplier = (Supplier) mDataSourceSupplierFiled.get(controller); Field mAutoField = Class.forName("com.facebook.drawee.controller.AbstractDraweeControllerBuilder$2").getDeclaredField("this$0"); mAutoField.setAccessible(true); PipelineDraweeControllerBuilder builder = (PipelineDraweeControllerBuilder) mAutoField.get(supplier); return builder; } catch (Exception e) { e.printStackTrace(); } return null; }
Example #21
Source File: UETFresco.java From UETool with MIT License | 5 votes |
private String isSupportAnimation(DraweeView draweeView) { PipelineDraweeControllerBuilder builder = getFrescoControllerBuilder(draweeView); if (builder != null) { return String.valueOf(builder.getAutoPlayAnimations()).toUpperCase(); } return ""; }
Example #22
Source File: UETFresco.java From UETool with MIT License | 5 votes |
private String getImageURI(DraweeView draweeView) { PipelineDraweeControllerBuilder builder = getFrescoControllerBuilder(draweeView); if (builder != null) { return builder.getImageRequest().getSourceUri().toString(); } return ""; }
Example #23
Source File: FacebookImageUtil.java From imsdk-android with MIT License | 5 votes |
public static void loadFromResource(int resourceId, final SimpleDraweeView target) { ImageRequest request = ImageRequestBuilder.newBuilderWithResourceId(resourceId).build(); final PipelineDraweeControllerBuilder builder = Fresco.newDraweeControllerBuilder() .setImageRequest(request) .setOldController(target.getController()); handler.post(new Runnable() { @Override public void run() { DraweeController controller = builder.build(); target.setController(controller); } }); }
Example #24
Source File: FrescoImageLoader.java From FimiX8-RE with MIT License | 5 votes |
public static void display(SimpleDraweeView view, String lowUri, String uri, ControllerListener listener) { if (uri != null) { ImageRequestBuilder imageRequest; int w = view.getLayoutParams().width; int h = view.getLayoutParams().height; PipelineDraweeControllerBuilder controller = Fresco.newDraweeControllerBuilder(); if (!lowUri.startsWith("file:///")) { lowUri = "file://" + lowUri; } if (lowUri != null && lowUri.length() > 0) { controller.setLowResImageRequest(ImageRequest.fromUri(lowUri)); } controller.setOldController(view.getController()); controller.setAutoPlayAnimations(true); if (uri.endsWith(".MP4")) { imageRequest = ImageRequestBuilder.newBuilderWithSource(Uri.parse(lowUri)); } else { imageRequest = ImageRequestBuilder.newBuilderWithSource(Uri.parse(uri)); } if (w > 0 && h > 0) { imageRequest.setResizeOptions(new ResizeOptions(w, h)); } controller.setImageRequest(imageRequest.build()); controller.setControllerListener(listener); view.setController(controller.build()); } }
Example #25
Source File: FrescoUtils.java From FimiX8-RE with MIT License | 5 votes |
public static void displayPhoto(SimpleDraweeView mSimpleDraweeView, String path, int width, int height, ControllerListener mControllerListener) { if (!TextUtils.isEmpty(path)) { PipelineDraweeControllerBuilder mPipelineDraweeControllerBuilder = Fresco.newDraweeControllerBuilder(); ImageRequestBuilder mImageRequestBuilder = ImageRequestBuilder.newBuilderWithSource(Uri.parse(path)); mImageRequestBuilder.setResizeOptions(new ResizeOptions(width, height)); mPipelineDraweeControllerBuilder.setOldController(mSimpleDraweeView.getController()); mPipelineDraweeControllerBuilder.setImageRequest(mImageRequestBuilder.build()); mPipelineDraweeControllerBuilder.setControllerListener(mControllerListener); mSimpleDraweeView.setController(mPipelineDraweeControllerBuilder.build()); } }
Example #26
Source File: FrescoPlusCore.java From FrescoPlus with Apache License 2.0 | 4 votes |
/** * @return create a new DraweeControllerBuilder instance. */ public static PipelineDraweeControllerBuilder newDraweeControllerBuilder() { ParamCheckUtil.checkNotNull(mDraweeControllerBuilderSupplier,"FrescoPlusCore not initialize"); return mDraweeControllerBuilderSupplier.get(); }
Example #27
Source File: FrescoLoader.java From ImageLoader with Apache License 2.0 | 4 votes |
private void requestForImageView(ImageView imageView,final SingleConfig config) { /* config.setBitmapListener(new SingleConfig.BitmapListener() { @Override public void onSuccess(Bitmap bitmap) { imageView.setImageBitmap(bitmap); } @Override public void onFail(Throwable e) { if(config.getErrorResId() >0){ imageView.setImageResource(config.getErrorResId()); } } }); requestBitmap(config); return;*/ checkWrapContentOrMatchParent(config); //GenericDraweeHierarchy hierarchy=null; GenericDraweeHierarchy hierarchy = GenericDraweeHierarchyBuilder.newInstance(imageView.getContext().getResources()).build(); setupHierarchy(hierarchy,config); // 数据-model ImageRequest request = buildRequest(config); //设置controller DraweeHolder draweeHolder= (DraweeHolder) imageView.getTag(R.id.fresco_drawee); PipelineDraweeControllerBuilder controllerBuilder = buildPipelineDraweeController(config,request); if (draweeHolder == null) { draweeHolder=DraweeHolder.create(hierarchy,imageView.getContext()); }else { controllerBuilder.setOldController(draweeHolder.getController()); draweeHolder.setHierarchy(hierarchy); } draweeHolder.setController(controllerBuilder.build()); //imageview的特殊处理 ViewStatesListener mStatesListener=new ViewStatesListener(draweeHolder); imageView.addOnAttachStateChangeListener(mStatesListener); // 判断是否ImageView已经 attachToWindow if (ViewCompat.isAttachedToWindow(imageView)) { draweeHolder.onAttach(); } //设置scaletype //setImageViewScaleType(imageView,config); // if (ViewC.isAttachedToWindow()) { // draweeHolder.onAttach(); // } // 保证每一个ImageView中只存在一个draweeHolder imageView.setTag(R.id.fresco_drawee,draweeHolder); // 拿到数据 imageView.setImageDrawable(draweeHolder.getTopLevelDrawable()); }
Example #28
Source File: ImageManager.java From redgram-for-reddit with GNU General Public License v3.0 | 4 votes |
private static PipelineDraweeControllerBuilder getControllerBuilderInstance(){ return Fresco.newDraweeControllerBuilder(); }
Example #29
Source File: ImageManager.java From redgram-for-reddit with GNU General Public License v3.0 | 4 votes |
public SingleImageBuilder setControllerBuilder(PipelineDraweeControllerBuilder controllerBuilder) { this.controllerBuilder = controllerBuilder; return this; }
Example #30
Source File: ImageManager.java From redgram-for-reddit with GNU General Public License v3.0 | 4 votes |
public PipelineDraweeControllerBuilder getControllerBuilder() { return controllerBuilder; }