mirror of
https://github.com/status-im/react-native.git
synced 2025-01-28 02:04:55 +00:00
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:
parent
f331d2a844
commit
e4f0971a55
@ -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
|
||||
protected void onAfterUpdateTransaction(ReactImageView view) {
|
||||
super.onAfterUpdateTransaction(view);
|
||||
|
@ -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);
|
||||
|
Loading…
x
Reference in New Issue
Block a user