From e4f0971a55d386db93ff5c78d383ffae1132dc33 Mon Sep 17 00:00:00 2001 From: olivier notteghem Date: Mon, 16 Nov 2015 13:49:59 -0800 Subject: [PATCH] Re-land D2656590 in iOS repo which is the source of truth Reviewed By: newobj Differential Revision: D2660019 fb-gh-sync-id: 7cc183888f88d9971f59b23f45a86b5aa0391909 --- .../react/views/image/ReactImageManager.java | 10 +++++++ .../react/views/image/ReactImageView.java | 27 +++++++++++-------- 2 files changed, 26 insertions(+), 11 deletions(-) diff --git a/ReactAndroid/src/main/java/com/facebook/react/views/image/ReactImageManager.java b/ReactAndroid/src/main/java/com/facebook/react/views/image/ReactImageManager.java index 62ef1d7ef..0158ff072 100644 --- a/ReactAndroid/src/main/java/com/facebook/react/views/image/ReactImageManager.java +++ b/ReactAndroid/src/main/java/com/facebook/react/views/image/ReactImageManager.java @@ -92,6 +92,16 @@ public class ReactImageManager extends SimpleViewManager { } } + @ReactProp(name = "progressiveRenderingEnabled") + public void setProgressiveRenderingEnabled(ReactImageView view, boolean enabled) { + view.setProgressiveRenderingEnabled(enabled); + } + + @ReactProp(name = "fadeDuration") + public void setFadeDuration(ReactImageView view, int durationMs) { + view.setFadeDuration(durationMs); + } + @Override protected void onAfterUpdateTransaction(ReactImageView view) { super.onAfterUpdateTransaction(view); diff --git a/ReactAndroid/src/main/java/com/facebook/react/views/image/ReactImageView.java b/ReactAndroid/src/main/java/com/facebook/react/views/image/ReactImageView.java index 14995c3e1..d741356fe 100644 --- a/ReactAndroid/src/main/java/com/facebook/react/views/image/ReactImageView.java +++ b/ReactAndroid/src/main/java/com/facebook/react/views/image/ReactImageView.java @@ -45,7 +45,6 @@ import com.facebook.react.uimanager.PixelUtil; public class ReactImageView extends GenericDraweeView { private static final int REMOTE_IMAGE_FADE_DURATION_MS = 300; - public static final String TAG = ReactImageView.class.getSimpleName(); /* * Implementation note re rounded corners: @@ -107,7 +106,8 @@ public class ReactImageView extends GenericDraweeView { private final RoundedCornerPostprocessor mRoundedCornerPostprocessor; private final @Nullable Object mCallerContext; private @Nullable ControllerListener mControllerListener; - private int mImageFadeDuration = -1; + private int mFadeDurationMs = -1; + private boolean mProgressiveRenderingEnabled; // We can't specify rounding in XML, so have to do so here private static GenericDraweeHierarchy buildHierarchy(Context context) { @@ -169,6 +169,16 @@ public class ReactImageView extends GenericDraweeView { mIsDirty = true; } + public void setProgressiveRenderingEnabled(boolean enabled) { + mProgressiveRenderingEnabled = enabled; + // no worth marking as dirty if it already rendered.. + } + + public void setFadeDuration(int durationMs) { + mFadeDurationMs = durationMs; + // no worth marking as dirty if it already rendered.. + } + public void maybeUpdateView() { if (!mIsDirty) { return; @@ -192,8 +202,9 @@ public class ReactImageView extends GenericDraweeView { roundingParams.setCornersRadius(hierarchyRadius); roundingParams.setBorder(mBorderColor, mBorderWidth); hierarchy.setRoundingParams(roundingParams); - hierarchy.setFadeDuration(mImageFadeDuration >= 0 - ? mImageFadeDuration + hierarchy.setFadeDuration( + mFadeDurationMs >= 0 + ? mFadeDurationMs : mIsLocalImage ? 0 : REMOTE_IMAGE_FADE_DURATION_MS); Postprocessor postprocessor = usePostprocessorScaling ? mRoundedCornerPostprocessor : null; @@ -203,6 +214,7 @@ public class ReactImageView extends GenericDraweeView { ImageRequest imageRequest = ImageRequestBuilder.newBuilderWithSource(mUri) .setPostprocessor(postprocessor) .setResizeOptions(resizeOptions) + .setProgressiveRenderingEnabled(mProgressiveRenderingEnabled) .build(); DraweeController draweeController = mDraweeControllerBuilder @@ -224,13 +236,6 @@ public class ReactImageView extends GenericDraweeView { maybeUpdateView(); } - // VisibleForTesting - public void setImageFadeDuration(int imageFadeDuration) { - mImageFadeDuration = imageFadeDuration; - mIsDirty = true; - maybeUpdateView(); - } - @Override protected void onSizeChanged(int w, int h, int oldw, int oldh) { super.onSizeChanged(w, h, oldw, oldh);