mirror of
https://github.com/facebook/react-native.git
synced 2025-11-01 09:14:26 +00:00
Extend Android ImageViewManager to support analyticsTag prop
Summary: This diff extends the Android Image View manager to support the new analyticsTag prop. this prop is going to be used to track performance for images in android changelog: [Android][Added] Add analyticsTag prop into ImageView component Reviewed By: JoshuaGross Differential Revision: D20880602 fbshipit-source-id: e302e8fa83706e6517b228d44a3094a1686830f7
This commit is contained in:
committed by
Facebook GitHub Bot
parent
f7b90336be
commit
72150f57ce
+2
-1
@@ -7,6 +7,7 @@
|
||||
|
||||
package com.facebook.react.views.image;
|
||||
|
||||
import androidx.annotation.Nullable;
|
||||
import com.facebook.react.uimanager.ThemedReactContext;
|
||||
|
||||
/**
|
||||
@@ -21,5 +22,5 @@ public interface ReactCallerContextFactory {
|
||||
* @param reactContext {@link ThemedReactContext} used to create the {@link ReactImageView}
|
||||
* @return an {@link Object} that represents the CallerContext.
|
||||
*/
|
||||
Object getOrCreateCallerContext(ThemedReactContext reactContext);
|
||||
Object getOrCreateCallerContext(ThemedReactContext reactContext, @Nullable String analyticTag);
|
||||
}
|
||||
|
||||
@@ -107,7 +107,7 @@ public class ReactImageManager extends SimpleViewManager<ReactImageView> {
|
||||
public ReactImageView createViewInstance(ThemedReactContext context) {
|
||||
Object callerContext =
|
||||
mCallerContextFactory != null
|
||||
? mCallerContextFactory.getOrCreateCallerContext(context)
|
||||
? mCallerContextFactory.getOrCreateCallerContext(context, null)
|
||||
: getCallerContext();
|
||||
return new ReactImageView(
|
||||
context, getDraweeControllerBuilder(), mGlobalImageLoadListener, callerContext);
|
||||
@@ -124,6 +124,15 @@ public class ReactImageManager extends SimpleViewManager<ReactImageView> {
|
||||
view.setBlurRadius(blurRadius);
|
||||
}
|
||||
|
||||
@ReactProp(name = "analyticTag")
|
||||
public void setAnalyticsTag(ReactImageView view, @Nullable String analyticTag) {
|
||||
if (mCallerContextFactory != null) {
|
||||
view.updateCallerContext(
|
||||
mCallerContextFactory.getOrCreateCallerContext(
|
||||
(ThemedReactContext) view.getContext(), analyticTag));
|
||||
}
|
||||
}
|
||||
|
||||
// In JS this is Image.props.defaultSource
|
||||
@ReactProp(name = "defaultSrc")
|
||||
public void setDefaultSource(ReactImageView view, @Nullable String source) {
|
||||
|
||||
@@ -90,6 +90,11 @@ public class ReactImageView extends GenericDraweeView {
|
||||
private static final Matrix sInverse = new Matrix();
|
||||
private ImageResizeMethod mResizeMethod = ImageResizeMethod.AUTO;
|
||||
|
||||
public void updateCallerContext(@Nullable Object callerContext) {
|
||||
mCallerContext = callerContext;
|
||||
mIsDirty = true;
|
||||
}
|
||||
|
||||
private class RoundedCornerPostprocessor extends BasePostprocessor {
|
||||
|
||||
void getRadii(Bitmap source, float[] computedCornerRadii, float[] mappedRadii) {
|
||||
@@ -197,7 +202,7 @@ public class ReactImageView extends GenericDraweeView {
|
||||
private @Nullable ControllerListener mControllerListener;
|
||||
private @Nullable ControllerListener mControllerForTesting;
|
||||
private @Nullable GlobalImageLoadListener mGlobalImageLoadListener;
|
||||
private final @Nullable Object mCallerContext;
|
||||
private @Nullable Object mCallerContext;
|
||||
private int mFadeDurationMs = -1;
|
||||
private boolean mProgressiveRenderingEnabled;
|
||||
private ReadableMap mHeaders;
|
||||
|
||||
Reference in New Issue
Block a user