From adea8d5fc928246ccf8ec5a8b1ccde159c2d6e09 Mon Sep 17 00:00:00 2001 From: Felix Oghina Date: Fri, 1 Jul 2016 10:46:11 -0700 Subject: [PATCH] use MultiSourceHelper in PhotoViewer Reviewed By: andreicoman11 Differential Revision: D3509011 fbshipit-source-id: 96fe96f28da24efb00b98589cea28e6c9cfc7180 --- .../views/imagehelper/MultiSourceHelper.java | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/ReactAndroid/src/main/java/com/facebook/react/views/imagehelper/MultiSourceHelper.java b/ReactAndroid/src/main/java/com/facebook/react/views/imagehelper/MultiSourceHelper.java index 5dba715ab..ef3f4f981 100644 --- a/ReactAndroid/src/main/java/com/facebook/react/views/imagehelper/MultiSourceHelper.java +++ b/ReactAndroid/src/main/java/com/facebook/react/views/imagehelper/MultiSourceHelper.java @@ -51,17 +51,28 @@ public class MultiSourceHelper { } } + public static MultiSourceResult getBestSourceForSize( + int width, + int height, + List sources) { + return getBestSourceForSize(width, height, sources, 1.0d); + } + /** * Chooses the image source with the size closest to the target image size. * * @param width the width of the view that will be used to display this image * @param height the height of the view that will be used to display this image * @param sources the list of potential image sources to choose from + * @param multiplier the area of the view will be multiplied by this number before calculating the + * best source; this is useful if the image will be displayed bigger than the view + * (e.g. zoomed) */ public static MultiSourceResult getBestSourceForSize( int width, int height, - List sources) { + List sources, + double multiplier) { // no sources if (sources.isEmpty()) { return new MultiSourceResult(null, null); @@ -81,7 +92,7 @@ public class MultiSourceHelper { ImagePipeline imagePipeline = ImagePipelineFactory.getInstance().getImagePipeline(); ImageSource best = null; ImageSource bestCached = null; - final double viewArea = width * height; + final double viewArea = width * height * multiplier; double bestPrecision = Double.MAX_VALUE; double bestCachePrecision = Double.MAX_VALUE; for (ImageSource source : sources) {