Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Mark nullsafe fixmes in views/text/frescosupport #48613

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
import com.facebook.common.logging.FLog;
import com.facebook.common.util.UriUtil;
import com.facebook.drawee.controller.AbstractDraweeControllerBuilder;
import com.facebook.infer.annotation.Nullsafe;
import com.facebook.react.bridge.Dynamic;
import com.facebook.react.bridge.ReadableArray;
import com.facebook.react.bridge.ReadableMap;
Expand All @@ -27,9 +28,11 @@
import java.util.Locale;

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

private @Nullable Uri mUri;
// NULLSAFE_FIXME[Field Not Initialized]
private ReadableMap mHeaders;
private final AbstractDraweeControllerBuilder mDraweeControllerBuilder;
private final @Nullable Object mCallerContext;
Expand All @@ -47,6 +50,7 @@ public FrescoBasedReactTextInlineImageShadowNode(
@ReactProp(name = "src")
public void setSource(@Nullable ReadableArray sources) {
final String source =
// NULLSAFE_FIXME[Nullable Dereference]
(sources == null || sources.size() == 0) ? null : sources.getMap(0).getString("uri");
Uri uri = null;
if (source != null) {
Expand Down Expand Up @@ -145,6 +149,7 @@ public TextInlineImageSpan buildInlineImageSpan() {
getHeaders(),
getDraweeControllerBuilder(),
getCallerContext(),
// NULLSAFE_FIXME[Parameter Not Nullable]
mResizeMode);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
import com.facebook.drawee.view.DraweeHolder;
import com.facebook.imagepipeline.request.ImageRequest;
import com.facebook.imagepipeline.request.ImageRequestBuilder;
import com.facebook.infer.annotation.Nullsafe;
import com.facebook.react.bridge.ReadableMap;
import com.facebook.react.modules.fresco.ReactNetworkImageRequest;
import com.facebook.react.uimanager.PixelUtil;
Expand All @@ -40,6 +41,7 @@
* <p>Note: It borrows code from DynamicDrawableSpan and if that code updates how it computes size
* or draws, we need to update this as well.
*/
@Nullsafe(Nullsafe.Mode.LOCAL)
class FrescoBasedReactTextInlineImageSpan extends TextInlineImageSpan {

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

// NULLSAFE_FIXME[Inconsistent Subclass Parameter Annotation]
public void setTextView(TextView textView) {
mTextView = textView;
}
Expand All @@ -140,17 +143,21 @@ public void draw(
mDraweeControllerBuilder
.reset()
.setOldController(mDraweeHolder.getController())
// NULLSAFE_FIXME[Parameter Not Nullable]
.setCallerContext(mCallerContext)
.setImageRequest(imageRequest)
.build();
mDraweeHolder.setController(draweeController);
mDraweeControllerBuilder.reset();

mDrawable = mDraweeHolder.getTopLevelDrawable();
// NULLSAFE_FIXME[Nullable Dereference]
mDrawable.setBounds(0, 0, mWidth, mHeight);
if (mTintColor != 0) {
// NULLSAFE_FIXME[Nullable Dereference]
mDrawable.setColorFilter(mTintColor, PorterDuff.Mode.SRC_IN);
}
// NULLSAFE_FIXME[Nullable Dereference]
mDrawable.setCallback(mTextView);
}

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

canvas.translate(x, transY);
// NULLSAFE_FIXME[Nullable Dereference]
mDrawable.draw(canvas);
canvas.restore();
}
Expand Down
Loading