com.facebook.datasource.BaseDataSubscriber Java Examples
The following examples show how to use
com.facebook.datasource.BaseDataSubscriber.
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: FrescoController.java From base-module with Apache License 2.0 | 5 votes |
/** * 只下载图片到磁盘,可设置下载回调 * @param context * @param baseDataSubscriber */ public void downloadOnly(Context context, BaseDataSubscriber baseDataSubscriber) { ImageRequest imageRequest = ImageRequestBuilder.newBuilderWithSource(mUri) .setProgressiveRenderingEnabled(true) .build(); ImagePipeline imagePipeline = Fresco.getImagePipeline(); DataSource<Void> dataSource = imagePipeline.prefetchToDiskCache(imageRequest, context.getApplicationContext()); if(baseDataSubscriber != null) { dataSource.subscribe(baseDataSubscriber, UiThreadImmediateExecutorService.getInstance()); } }
Example #2
Source File: FrescoUtils.java From materialup with Apache License 2.0 | 4 votes |
private static final void setSubscribe(Context context, ImageRequest request, BaseDataSubscriber subscriber) { ImagePipeline imagePipeline = Fresco.getImagePipeline(); DataSource<CloseableReference<CloseableImage>> dataSource = imagePipeline.fetchDecodedImage(request, context); dataSource.subscribe(subscriber, CallerThreadExecutor.getInstance()); }
Example #3
Source File: FrescoUtils.java From materialup with Apache License 2.0 | 4 votes |
public static final void setShotUrl(DraweeView view, String url, String thumbnail, BaseDataSubscriber subscriber, boolean full) { if (TextUtils.isEmpty(thumbnail) && TextUtils.isEmpty(url)) { return; } ImageRequest imageRequest = ImageRequestBuilder.newBuilderWithSource(Uri.parse(url)) // .setResizeOptions( // new ResizeOptions(300, 400)) .setProgressiveRenderingEnabled(true) .build(); ImageRequest lowRequest = null; if (!TextUtils.isEmpty(thumbnail)) { lowRequest = ImageRequest.fromUri(thumbnail); } if (subscriber != null) { if (lowRequest != null && !full) { setSubscribe(view.getContext(), lowRequest, subscriber); } else if (imageRequest != null) { setSubscribe(view.getContext(), imageRequest, subscriber); } } DraweeController draweeController = Fresco.newDraweeControllerBuilder() .setImageRequest(imageRequest) .setLowResImageRequest(lowRequest) .setOldController(view.getController()) .setAutoPlayAnimations(true) // .setControllerListener(listener) .build(); // ImagePipeline imagePipeline = Fresco.getImagePipeline(); // ImageRequest request = lowRequest == null ? imageRequest : lowRequest; // DataSource<CloseableReference<CloseableImage>> dataSource = // imagePipeline.fetchDecodedImage(request, view.getContext()); // dataSource.subscribe(new BaseBitmapDataSubscriber() { // @Override // protected void onFailureImpl(DataSource<CloseableReference<CloseableImage>> dataSource) { // // } // // @Override protected void onNewResultImpl(@Nullable Bitmap bitmap) { // Palette.from(bitmap).maximumColorCount(3).generate(new Palette.PaletteAsyncListener() { // @Override public void onGenerated(Palette palette) { // } // }); // } // }, CallerThreadExecutor.getInstance()); view.setController(draweeController); }