Add docs for Fresco image attribution

Reviewed By: passy

Differential Revision: D15900104

fbshipit-source-id: 90f53fefbedfa32ed275900542f94650f487a679
This commit is contained in:
Alexander Oprisnik
2019-06-20 04:46:59 -07:00
committed by Facebook Github Bot
parent 3307576cb7
commit c22bdbe205

View File

@@ -61,4 +61,28 @@ client.addPlugin(new FrescoFlipperPlugin(
new NoOpFlipperPerfLogger(),
null,
leakTracker));
```
```
### Attribution
In order to annotate images with the context they are used in, you have to set a
caller context when loading the image. This can be any object, so for the simplest
case, a String will suffice.
```java
String callerContext = "my_feature";
// For DraweeViews:
draweeView.setImageURI(uri, callerContext);
// For prefetching:
ImagePipeline imagePipeline = Fresco.getImagePipeline();
imagePipeline.prefetchToDiskCache(imageRequest, callerContext);
// For manually fetching an image:
DataSource<CloseableReference<CloseableImage>>
dataSource = imagePipeline.fetchDecodedImage(imageRequest, callerContext);
```
If a caller context is supplied, the image will be properly attributed in the
Flipper image plugin.