Java Code Examples for com.facebook.imagepipeline.request.ImageRequest#CacheChoice

The following examples show how to use com.facebook.imagepipeline.request.ImageRequest#CacheChoice . 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: FacebookImageUtil.java    From imsdk-android with MIT License 6 votes vote down vote up
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 2
Source File: ImagePipeline.java    From fresco with MIT License 5 votes vote down vote up
/**
 * Performs disk cache check synchronously. It is not recommended to use this unless you know what
 * exactly you are doing. Disk cache check is a costly operation, the call will block the caller
 * thread until the cache check is completed.
 *
 * @param imageRequest the imageRequest for the image to be looked up.
 * @return true if the image was found in the disk cache, false otherwise.
 */
public boolean isInDiskCacheSync(final ImageRequest imageRequest) {
  final CacheKey cacheKey = mCacheKeyFactory.getEncodedCacheKey(imageRequest, null);
  final ImageRequest.CacheChoice cacheChoice = imageRequest.getCacheChoice();

  switch (cacheChoice) {
    case DEFAULT:
      return mMainBufferedDiskCache.diskCheckSync(cacheKey);
    case SMALL:
      return mSmallImageBufferedDiskCache.diskCheckSync(cacheKey);
    default:
      return false;
  }
}
 
Example 3
Source File: FacebookImageUtil.java    From imsdk-android with MIT License 4 votes vote down vote up
public static void loadWithCache(String url, final SimpleDraweeView target,
                                 boolean thumb, ImageRequest.CacheChoice type,final ImageLoadCallback callback) {
    loadWithCache(url,target,thumb,false,type,callback);
}
 
Example 4
Source File: EncodedImageOptions.java    From fresco with MIT License 4 votes vote down vote up
public @Nullable ImageRequest.CacheChoice getCacheChoice() {
  return mCacheChoice;
}
 
Example 5
Source File: ImagePipeline.java    From fresco with MIT License 2 votes vote down vote up
/**
 * Returns whether the image is stored in the disk cache. Performs disk cache check synchronously.
 * It is not recommended to use this unless you know what exactly you are doing. Disk cache check
 * is a costly operation, the call will block the caller thread until the cache check is
 * completed.
 *
 * @param uri the uri for the image to be looked up.
 * @param cacheChoice the cacheChoice for the cache to be looked up.
 * @return true if the image was found in the disk cache, false otherwise.
 */
public boolean isInDiskCacheSync(final Uri uri, final ImageRequest.CacheChoice cacheChoice) {
  ImageRequest imageRequest =
      ImageRequestBuilder.newBuilderWithSource(uri).setCacheChoice(cacheChoice).build();
  return isInDiskCacheSync(imageRequest);
}