From c22bdbe20518eeef409ab6ef8299a9284e57da03 Mon Sep 17 00:00:00 2001 From: Alexander Oprisnik Date: Thu, 20 Jun 2019 04:46:59 -0700 Subject: [PATCH] Add docs for Fresco image attribution Reviewed By: passy Differential Revision: D15900104 fbshipit-source-id: 90f53fefbedfa32ed275900542f94650f487a679 --- docs/setup/images-plugin.md | 26 +++++++++++++++++++++++++- 1 file changed, 25 insertions(+), 1 deletion(-) diff --git a/docs/setup/images-plugin.md b/docs/setup/images-plugin.md index e31c077c9..83de72ad8 100644 --- a/docs/setup/images-plugin.md +++ b/docs/setup/images-plugin.md @@ -61,4 +61,28 @@ client.addPlugin(new FrescoFlipperPlugin( new NoOpFlipperPerfLogger(), null, leakTracker)); -``` \ No newline at end of file +``` + +### 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> + dataSource = imagePipeline.fetchDecodedImage(imageRequest, callerContext); +``` + +If a caller context is supplied, the image will be properly attributed in the +Flipper image plugin.