Re-land D2656590 in iOS repo which is the source of truth

Reviewed By: newobj

Differential Revision: D2660019

fb-gh-sync-id: 7cc183888f88d9971f59b23f45a86b5aa0391909
This commit is contained in:
olivier notteghem 2015-11-16 13:49:59 -08:00 committed by facebook-github-bot-7
parent f331d2a844
commit e4f0971a55
2 changed files with 26 additions and 11 deletions

View File

@ -92,6 +92,16 @@ public class ReactImageManager extends SimpleViewManager<ReactImageView> {
} }
} }
@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 @Override
protected void onAfterUpdateTransaction(ReactImageView view) { protected void onAfterUpdateTransaction(ReactImageView view) {
super.onAfterUpdateTransaction(view); super.onAfterUpdateTransaction(view);

View File

@ -45,7 +45,6 @@ import com.facebook.react.uimanager.PixelUtil;
public class ReactImageView extends GenericDraweeView { public class ReactImageView extends GenericDraweeView {
private static final int REMOTE_IMAGE_FADE_DURATION_MS = 300; private static final int REMOTE_IMAGE_FADE_DURATION_MS = 300;
public static final String TAG = ReactImageView.class.getSimpleName();
/* /*
* Implementation note re rounded corners: * Implementation note re rounded corners:
@ -107,7 +106,8 @@ public class ReactImageView extends GenericDraweeView {
private final RoundedCornerPostprocessor mRoundedCornerPostprocessor; private final RoundedCornerPostprocessor mRoundedCornerPostprocessor;
private final @Nullable Object mCallerContext; private final @Nullable Object mCallerContext;
private @Nullable ControllerListener mControllerListener; 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 // We can't specify rounding in XML, so have to do so here
private static GenericDraweeHierarchy buildHierarchy(Context context) { private static GenericDraweeHierarchy buildHierarchy(Context context) {
@ -169,6 +169,16 @@ public class ReactImageView extends GenericDraweeView {
mIsDirty = true; 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() { public void maybeUpdateView() {
if (!mIsDirty) { if (!mIsDirty) {
return; return;
@ -192,8 +202,9 @@ public class ReactImageView extends GenericDraweeView {
roundingParams.setCornersRadius(hierarchyRadius); roundingParams.setCornersRadius(hierarchyRadius);
roundingParams.setBorder(mBorderColor, mBorderWidth); roundingParams.setBorder(mBorderColor, mBorderWidth);
hierarchy.setRoundingParams(roundingParams); hierarchy.setRoundingParams(roundingParams);
hierarchy.setFadeDuration(mImageFadeDuration >= 0 hierarchy.setFadeDuration(
? mImageFadeDuration mFadeDurationMs >= 0
? mFadeDurationMs
: mIsLocalImage ? 0 : REMOTE_IMAGE_FADE_DURATION_MS); : mIsLocalImage ? 0 : REMOTE_IMAGE_FADE_DURATION_MS);
Postprocessor postprocessor = usePostprocessorScaling ? mRoundedCornerPostprocessor : null; Postprocessor postprocessor = usePostprocessorScaling ? mRoundedCornerPostprocessor : null;
@ -203,6 +214,7 @@ public class ReactImageView extends GenericDraweeView {
ImageRequest imageRequest = ImageRequestBuilder.newBuilderWithSource(mUri) ImageRequest imageRequest = ImageRequestBuilder.newBuilderWithSource(mUri)
.setPostprocessor(postprocessor) .setPostprocessor(postprocessor)
.setResizeOptions(resizeOptions) .setResizeOptions(resizeOptions)
.setProgressiveRenderingEnabled(mProgressiveRenderingEnabled)
.build(); .build();
DraweeController draweeController = mDraweeControllerBuilder DraweeController draweeController = mDraweeControllerBuilder
@ -224,13 +236,6 @@ public class ReactImageView extends GenericDraweeView {
maybeUpdateView(); maybeUpdateView();
} }
// VisibleForTesting
public void setImageFadeDuration(int imageFadeDuration) {
mImageFadeDuration = imageFadeDuration;
mIsDirty = true;
maybeUpdateView();
}
@Override @Override
protected void onSizeChanged(int w, int h, int oldw, int oldh) { protected void onSizeChanged(int w, int h, int oldw, int oldh) {
super.onSizeChanged(w, h, oldw, oldh); super.onSizeChanged(w, h, oldw, oldh);