-
Notifications
You must be signed in to change notification settings - Fork 3.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Expose Cached Files #80
Comments
May I ask why do you need to know whether the image is cached or not? I think in most cases this is not what you really need. I mean, this information on its own is useless, what's important is what do you intend to do after you would find out whether the image is cached or not. For the second question, this is already possible. You can submit image request to the pipeline and the pipeline will return you the image. You can request encoded bytes (usually the bytes of the JPEG image) or decoded image (usually the Bitamp). In both cases you can tell the pipeline how deep it is allowed to go to satisfy your request. There are 4 levels: We can't/won't expose the real file name in disk cache because:
|
The reason you may want to know if the image is in the cache or not is to be able to present to the user a status of how available the app is for offline use. For example, if you have a photo gallery of 80 images pulled from remotes urls it would be useful to display to the user that they have 65 images of 80 cached locally so they can view them even when they are not connected to a network. Of course they would be able to see that in the photogallery but that may be after the fact. Another similar case is giving the user the ability to tap a button to download all images which prompts a sync adapter to pull the 80 images using your prefetching capability. We can easily do that part but we lose the ability to show the user that all of the images were successfully retrieved and not subsequently purged from the cache. Instead of having a callback and creating a data store recording which images are downloaded to have another view show progress (and which would later be out of date if the certain images were cleared from the cache). We could have a view check to see which images were in the cache and display the progress to the user. There is value in knowing whether an image is present in the disk cache and thus persistable. It is also completely understood why you don't want to expose the file name per se and it sounds like that is not needed because we can use the method you propose above. However, knowing whether the image is is in the disk cache would be very useful. Maybe something you want to think about is making a flag on certain items so they will not be removed unless a hard flush of the cache is performed. |
Alright, it shouldn't be hard to add |
I have different size of image, when user click thumb image , it will be displaying huge images (it can be 15000px * 2000px), includes pinch to zoom, panning, rotation and animation support. So it can not be encoded, I need to just download it , get image path , use webview or SubsamplingScaleImageView to show . Use also can save the image to designated location |
@leelei Fresco was not built with that big images in mind. |
That's why I just need to download , get image path |
@plamenko , I'm trying to do something similar to what you described in your first response as my use case is sharing the downloaded image, but because the DataSource<CloseableReference<PooledByteBuffer>> dataSource = Fresco.getImagePipeline().fetchEncodedImage(ImageRequest.fromUri(imageUri), getActivity());
try {
CloseableReference<PooledByteBuffer> bytes = dataSource.getResult();
if (bytes != null) {
try {
PooledByteBuffer pooledByteBuffer = bytes.get();
File tempFile = File.createTempFile("t", "jpg");
CommonIOUtil.writeToFile(tempFile, pooledByteBuffer.getStream());
Intent intent = new Intent(Intent.ACTION_VIEW);
intent.setDataAndType(Uri.fromFile(tempFile), animatable != null ? "image/gif" : "image/*");
getActivity().startActivity(intent);
} catch (IOException e) {
e.printStackTrace();
} finally {
CloseableReference.closeSafely(bytes);
}
}
} finally {
dataSource.close();
} |
You need to subscribe to the datasource. See http://frescolib.org/docs/datasources-datasubscribers.html#_ |
Any updates on this issue? Do you have an idea of when the calls might be implemented? |
ImageRequest imageRequest=ImageRequest.fromUri(uriString); |
Added in 0.7.0. |
Hi, Could someone please post sample code on how this task can be accomplished in 0.7.0 or above? I'm struggling to find the correct method to call to accomplish this. Thanks! |
|
I'm using fetchEncodedImage to get the bitmap of a local file: |
It would be nice to have the ability to see if the image has already been cached to disk and/or memory. A simple call like
Maybe a separate request but related is the ability to retrieve the cached resource from disk. The use case being that after we have retrieved the image the app may have a feature that allows the user to share the image. If we could access the local uri of the cached image then we can pass it to share intent.
The text was updated successfully, but these errors were encountered: