Java Code Examples for com.facebook.imagepipeline.core.ImagePipeline#prefetchToDiskCache()
The following examples show how to use
com.facebook.imagepipeline.core.ImagePipeline#prefetchToDiskCache() .
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: FrescoVitoPrefetcherImpl.java From fresco with MIT License | 6 votes |
@Nullable public DataSource<Void> prefetch( final PrefetchTarget prefetchTarget, final VitoImageRequest imageRequest, @Nullable final Object callerContext) { final ImageRequest finalImageRequest = imageRequest.finalImageRequest; if (finalImageRequest == null) { return null; } mFrescoContext.verifyCallerContext(callerContext); final ImagePipeline pipeline = mFrescoContext.getImagePipeline(); switch (prefetchTarget) { case MEMORY_DECODED: return pipeline.prefetchToBitmapCache(finalImageRequest, callerContext); case MEMORY_ENCODED: return pipeline.prefetchToEncodedCache(finalImageRequest, callerContext); case DISK: return pipeline.prefetchToDiskCache(finalImageRequest, callerContext); } return DataSources.immediateFailedDataSource( new CancellationException("Prefetching is not enabled")); }
Example 2
Source File: FrescoImageProvider.java From HybridCache with MIT License | 5 votes |
private DataSource<Void> prefetchToDiskCache(String url, ImageRequestListener listener) { if (!TextUtils.isEmpty(url)) { ImagePipeline imagePipeline = Fresco.getImagePipeline(); ImageRequestBuilder builder = ImageRequestBuilder.newBuilderWithSource(Uri.parse(url)); if (listener != null) { builder.setRequestListener(new ImageRequestWrapper(listener)); } return imagePipeline.prefetchToDiskCache(builder.build(), null); } if (listener != null) { listener.onFailed(null, new Exception("url is empty")); } return null; }
Example 3
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 4
Source File: OffLineService.java From TLint with Apache License 2.0 | 5 votes |
private void cacheImage(String url) { if (!isImageDownloaded(Uri.parse(url))) { ImagePipeline imagePipeline = Fresco.getImagePipeline(); ImageRequest request = ImageRequest.fromUri(url); imagePipeline.prefetchToDiskCache(request, this); offlinePictureLength += request.getSourceFile().length(); offlinePictureCount++; } }
Example 5
Source File: BigImageLoader.java From ImageLoader with Apache License 2.0 | 4 votes |
@Override public void prefetch(Uri uri) { ImagePipeline pipeline = Fresco.getImagePipeline(); pipeline.prefetchToDiskCache(ImageRequest.fromUri(uri), false); // we don't need context, but avoid null }