Skip to content

Commit 95a5d84

Browse files
Thomas Nardonefacebook-github-bot
authored andcommitted
[skip ci] Mark nullsafe fixmes in views/text/frescosupport (facebook#48613)
Summary: First step for nullsafe - annotate and mark fixmes Changelog: [Internal] Reviewed By: rshest Differential Revision: D67992721
1 parent 85f9939 commit 95a5d84

File tree

2 files changed

+14
-0
lines changed

2 files changed

+14
-0
lines changed

packages/react-native/ReactAndroid/src/main/java/com/facebook/react/views/text/frescosupport/FrescoBasedReactTextInlineImageShadowNode.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
import com.facebook.common.logging.FLog;
1515
import com.facebook.common.util.UriUtil;
1616
import com.facebook.drawee.controller.AbstractDraweeControllerBuilder;
17+
import com.facebook.infer.annotation.Nullsafe;
1718
import com.facebook.react.bridge.Dynamic;
1819
import com.facebook.react.bridge.ReadableArray;
1920
import com.facebook.react.bridge.ReadableMap;
@@ -27,9 +28,11 @@
2728
import java.util.Locale;
2829

2930
/** Shadow node that represents an inline image. Loading is done using Fresco. */
31+
@Nullsafe(Nullsafe.Mode.LOCAL)
3032
class FrescoBasedReactTextInlineImageShadowNode extends ReactTextInlineImageShadowNode {
3133

3234
private @Nullable Uri mUri;
35+
// NULLSAFE_FIXME[Field Not Initialized]
3336
private ReadableMap mHeaders;
3437
private final AbstractDraweeControllerBuilder mDraweeControllerBuilder;
3538
private final @Nullable Object mCallerContext;
@@ -47,6 +50,7 @@ public FrescoBasedReactTextInlineImageShadowNode(
4750
@ReactProp(name = "src")
4851
public void setSource(@Nullable ReadableArray sources) {
4952
final String source =
53+
// NULLSAFE_FIXME[Nullable Dereference]
5054
(sources == null || sources.size() == 0) ? null : sources.getMap(0).getString("uri");
5155
Uri uri = null;
5256
if (source != null) {
@@ -145,6 +149,7 @@ public TextInlineImageSpan buildInlineImageSpan() {
145149
getHeaders(),
146150
getDraweeControllerBuilder(),
147151
getCallerContext(),
152+
// NULLSAFE_FIXME[Parameter Not Nullable]
148153
mResizeMode);
149154
}
150155

packages/react-native/ReactAndroid/src/main/java/com/facebook/react/views/text/frescosupport/FrescoBasedReactTextInlineImageSpan.java

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
import com.facebook.drawee.view.DraweeHolder;
2424
import com.facebook.imagepipeline.request.ImageRequest;
2525
import com.facebook.imagepipeline.request.ImageRequestBuilder;
26+
import com.facebook.infer.annotation.Nullsafe;
2627
import com.facebook.react.bridge.ReadableMap;
2728
import com.facebook.react.modules.fresco.ReactNetworkImageRequest;
2829
import com.facebook.react.uimanager.PixelUtil;
@@ -40,6 +41,7 @@
4041
* <p>Note: It borrows code from DynamicDrawableSpan and if that code updates how it computes size
4142
* or draws, we need to update this as well.
4243
*/
44+
@Nullsafe(Nullsafe.Mode.LOCAL)
4345
class FrescoBasedReactTextInlineImageSpan extends TextInlineImageSpan {
4446

4547
private @Nullable Drawable mDrawable;
@@ -116,6 +118,7 @@ public int getSize(Paint paint, CharSequence text, int start, int end, Paint.Fon
116118
return mWidth;
117119
}
118120

121+
// NULLSAFE_FIXME[Inconsistent Subclass Parameter Annotation]
119122
public void setTextView(TextView textView) {
120123
mTextView = textView;
121124
}
@@ -140,17 +143,21 @@ public void draw(
140143
mDraweeControllerBuilder
141144
.reset()
142145
.setOldController(mDraweeHolder.getController())
146+
// NULLSAFE_FIXME[Parameter Not Nullable]
143147
.setCallerContext(mCallerContext)
144148
.setImageRequest(imageRequest)
145149
.build();
146150
mDraweeHolder.setController(draweeController);
147151
mDraweeControllerBuilder.reset();
148152

149153
mDrawable = mDraweeHolder.getTopLevelDrawable();
154+
// NULLSAFE_FIXME[Nullable Dereference]
150155
mDrawable.setBounds(0, 0, mWidth, mHeight);
151156
if (mTintColor != 0) {
157+
// NULLSAFE_FIXME[Nullable Dereference]
152158
mDrawable.setColorFilter(mTintColor, PorterDuff.Mode.SRC_IN);
153159
}
160+
// NULLSAFE_FIXME[Nullable Dereference]
154161
mDrawable.setCallback(mTextView);
155162
}
156163

@@ -161,9 +168,11 @@ public void draw(
161168
// Align to center
162169
int fontHeight = (int) (paint.descent() - paint.ascent());
163170
int centerY = y + (int) paint.descent() - fontHeight / 2;
171+
// NULLSAFE_FIXME[Nullable Dereference]
164172
int transY = centerY - (mDrawable.getBounds().bottom - mDrawable.getBounds().top) / 2;
165173

166174
canvas.translate(x, transY);
175+
// NULLSAFE_FIXME[Nullable Dereference]
167176
mDrawable.draw(canvas);
168177
canvas.restore();
169178
}

0 commit comments

Comments
 (0)