Skip to content

Commit

Permalink
Nullsafe fabric/events classes (#44392)
Browse files Browse the repository at this point in the history
Summary:
Pull Request resolved: #44392

Updating null annotations to match convention.

Changelog: [Internal]

Reviewed By: NickGerleman

Differential Revision: D56895070

fbshipit-source-id: 05ef7d8ba7f3c4a8ec352336c86e1c02cf0bb601
  • Loading branch information
Thomas Nardone authored and facebook-github-bot committed May 7, 2024
1 parent 24aece3 commit 3f59d53
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
package com.facebook.react.fabric.events;

import android.annotation.SuppressLint;
import androidx.annotation.NonNull;
import com.facebook.infer.annotation.Nullsafe;
import com.facebook.jni.HybridData;
import com.facebook.proguard.annotations.DoNotStrip;
Expand All @@ -34,7 +33,7 @@ public final class EventBeatManager implements BatchEventDispatchedListener {
private native void tick();

@Deprecated(forRemoval = true, since = "Deprecated on v0.72.0 Use EventBeatManager() instead")
public EventBeatManager(@NonNull ReactApplicationContext reactApplicationContext) {
public EventBeatManager(ReactApplicationContext reactApplicationContext) {
this();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@
package com.facebook.react.fabric.events;

import android.annotation.SuppressLint;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import com.facebook.infer.annotation.Nullsafe;
import com.facebook.jni.HybridData;
import com.facebook.proguard.annotations.DoNotStrip;
import com.facebook.react.bridge.NativeMap;
Expand All @@ -21,6 +21,7 @@
* This class holds reference to the C++ EventEmitter object. Instances of this class are created in
* FabricMountingManager.cpp, where the pointer to the C++ event emitter is set.
*/
@Nullsafe(Nullsafe.Mode.LOCAL)
@DoNotStrip
@SuppressLint("MissingNativeLoadLibrary")
public class EventEmitterWrapper {
Expand All @@ -37,9 +38,9 @@ private EventEmitterWrapper(HybridData hybridData) {
}

private native void dispatchEvent(
@NonNull String eventName, @NonNull NativeMap params, @EventCategoryDef int category);
String eventName, @Nullable NativeMap params, @EventCategoryDef int category);

private native void dispatchUniqueEvent(@NonNull String eventName, @NonNull NativeMap params);
private native void dispatchUniqueEvent(String eventName, @Nullable NativeMap params);

/**
* Invokes the execution of the C++ EventEmitter.
Expand All @@ -48,9 +49,7 @@ private native void dispatchEvent(
* @param params {@link WritableMap} payload of the event
*/
public synchronized void dispatch(
@NonNull String eventName,
@Nullable WritableMap params,
@EventCategoryDef int eventCategory) {
String eventName, @Nullable WritableMap params, @EventCategoryDef int eventCategory) {
if (!isValid()) {
return;
}
Expand All @@ -64,7 +63,7 @@ public synchronized void dispatch(
* @param eventName {@link String} name of the event to execute.
* @param params {@link WritableMap} payload of the event
*/
public synchronized void dispatchUnique(@NonNull String eventName, @Nullable WritableMap params) {
public synchronized void dispatchUnique(String eventName, @Nullable WritableMap params) {
if (!isValid()) {
return;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@

package com.facebook.react.fabric.events;

import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import com.facebook.infer.annotation.Nullsafe;
import com.facebook.react.bridge.WritableArray;
Expand All @@ -22,14 +21,14 @@
@Nullsafe(Nullsafe.Mode.LOCAL)
public class FabricEventEmitter implements RCTModernEventEmitter {

@NonNull private final FabricUIManager mUIManager;
private final FabricUIManager mUIManager;

public FabricEventEmitter(@NonNull FabricUIManager uiManager) {
public FabricEventEmitter(FabricUIManager uiManager) {
mUIManager = uiManager;
}

@Override
public void receiveEvent(int reactTag, @NonNull String eventName, @Nullable WritableMap params) {
public void receiveEvent(int reactTag, String eventName, @Nullable WritableMap params) {
receiveEvent(ViewUtil.NO_SURFACE_ID, reactTag, eventName, params);
}

Expand Down Expand Up @@ -61,9 +60,7 @@ public void receiveEvent(
/** Touches are dispatched by {@link #receiveTouches(TouchEvent)} */
@Override
public void receiveTouches(
@NonNull String eventName,
@NonNull WritableArray touches,
@NonNull WritableArray changedIndices) {
String eventName, WritableArray touches, WritableArray changedIndices) {
throw new UnsupportedOperationException(
"EventEmitter#receiveTouches is not supported by Fabric");
}
Expand Down

0 comments on commit 3f59d53

Please sign in to comment.