mirror of
https://github.com/facebook/react-native.git
synced 2025-11-01 09:14:26 +00:00
Migrate Nullable and NonNull annotations to AndroidX
Summary: This diff migrates the usages Nullable and NonNull annotations to AndroidX instead of javax. The purpose of this change is to bring consistency in the annotations used by the core of RN Reviewed By: makovkastar Differential Revision: D16054504 fbshipit-source-id: 21d888854da088d2a14615a90d4dc058e5286b91
This commit is contained in:
committed by
Facebook Github Bot
parent
96318e438f
commit
aa5edca0e2
@@ -47,6 +47,7 @@ rn_android_library(
|
||||
],
|
||||
exported_deps = [
|
||||
":DisplayMetrics",
|
||||
react_native_dep("third-party/android/androidx:annotation"),
|
||||
react_native_dep("third-party/java/jsr-305:jsr-305"),
|
||||
react_native_target("java/com/facebook/react/uimanager/common:common"),
|
||||
],
|
||||
@@ -58,12 +59,16 @@ rn_android_library(
|
||||
"DisplayMetricsHolder.java",
|
||||
],
|
||||
is_androidx = True,
|
||||
provided_deps = [
|
||||
react_native_dep("third-party/android/androidx:annotation"),
|
||||
],
|
||||
required_for_source_only_abi = True,
|
||||
visibility = [
|
||||
"PUBLIC",
|
||||
],
|
||||
deps = [
|
||||
react_native_dep("third-party/java/infer-annotations:infer-annotations"),
|
||||
react_native_dep("third-party/android/androidx:annotation"),
|
||||
react_native_dep("third-party/java/jsr-305:jsr-305"),
|
||||
react_native_target("java/com/facebook/react/bridge:bridge"),
|
||||
],
|
||||
|
||||
@@ -9,6 +9,8 @@ import android.graphics.Color;
|
||||
import android.text.TextUtils;
|
||||
import android.view.View;
|
||||
import android.view.ViewParent;
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
import androidx.core.view.ViewCompat;
|
||||
import com.facebook.react.R;
|
||||
import com.facebook.react.bridge.Dynamic;
|
||||
@@ -24,8 +26,6 @@ import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import javax.annotation.Nonnull;
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
/**
|
||||
* Base class that should be suitable for the majority of subclasses of {@link ViewManager}. It
|
||||
@@ -85,12 +85,12 @@ public abstract class BaseViewManager<T extends View, C extends LayoutShadowNode
|
||||
private static final String STATE_MIXED = "mixed";
|
||||
|
||||
@ReactProp(name = PROP_BACKGROUND_COLOR, defaultInt = Color.TRANSPARENT, customType = "Color")
|
||||
public void setBackgroundColor(@Nonnull T view, int backgroundColor) {
|
||||
public void setBackgroundColor(@NonNull T view, int backgroundColor) {
|
||||
view.setBackgroundColor(backgroundColor);
|
||||
}
|
||||
|
||||
@ReactProp(name = PROP_TRANSFORM)
|
||||
public void setTransform(@Nonnull T view, @Nullable ReadableArray matrix) {
|
||||
public void setTransform(@NonNull T view, @Nullable ReadableArray matrix) {
|
||||
if (matrix == null) {
|
||||
resetTransformProperty(view);
|
||||
} else {
|
||||
@@ -99,17 +99,17 @@ public abstract class BaseViewManager<T extends View, C extends LayoutShadowNode
|
||||
}
|
||||
|
||||
@ReactProp(name = ViewProps.OPACITY, defaultFloat = 1.f)
|
||||
public void setOpacity(@Nonnull T view, float opacity) {
|
||||
public void setOpacity(@NonNull T view, float opacity) {
|
||||
view.setAlpha(opacity);
|
||||
}
|
||||
|
||||
@ReactProp(name = PROP_ELEVATION)
|
||||
public void setElevation(@Nonnull T view, float elevation) {
|
||||
public void setElevation(@NonNull T view, float elevation) {
|
||||
ViewCompat.setElevation(view, PixelUtil.toPixelFromDIP(elevation));
|
||||
}
|
||||
|
||||
@ReactProp(name = PROP_Z_INDEX)
|
||||
public void setZIndex(@Nonnull T view, float zIndex) {
|
||||
public void setZIndex(@NonNull T view, float zIndex) {
|
||||
int integerZIndex = Math.round(zIndex);
|
||||
ViewGroupManager.setViewZIndex(view, integerZIndex);
|
||||
ViewParent parent = view.getParent();
|
||||
@@ -119,12 +119,12 @@ public abstract class BaseViewManager<T extends View, C extends LayoutShadowNode
|
||||
}
|
||||
|
||||
@ReactProp(name = PROP_RENDER_TO_HARDWARE_TEXTURE)
|
||||
public void setRenderToHardwareTexture(@Nonnull T view, boolean useHWTexture) {
|
||||
public void setRenderToHardwareTexture(@NonNull T view, boolean useHWTexture) {
|
||||
view.setLayerType(useHWTexture ? View.LAYER_TYPE_HARDWARE : View.LAYER_TYPE_NONE, null);
|
||||
}
|
||||
|
||||
@ReactProp(name = PROP_TEST_ID)
|
||||
public void setTestId(@Nonnull T view, String testId) {
|
||||
public void setTestId(@NonNull T view, String testId) {
|
||||
view.setTag(R.id.react_test_id, testId);
|
||||
|
||||
// temporarily set the tag and keyed tags to avoid end to end test regressions
|
||||
@@ -132,25 +132,25 @@ public abstract class BaseViewManager<T extends View, C extends LayoutShadowNode
|
||||
}
|
||||
|
||||
@ReactProp(name = PROP_NATIVE_ID)
|
||||
public void setNativeId(@Nonnull T view, String nativeId) {
|
||||
public void setNativeId(@NonNull T view, String nativeId) {
|
||||
view.setTag(R.id.view_tag_native_id, nativeId);
|
||||
ReactFindViewUtil.notifyViewRendered(view);
|
||||
}
|
||||
|
||||
@ReactProp(name = PROP_ACCESSIBILITY_LABEL)
|
||||
public void setAccessibilityLabel(@Nonnull T view, String accessibilityLabel) {
|
||||
public void setAccessibilityLabel(@NonNull T view, String accessibilityLabel) {
|
||||
view.setTag(R.id.accessibility_label, accessibilityLabel);
|
||||
updateViewContentDescription(view);
|
||||
}
|
||||
|
||||
@ReactProp(name = PROP_ACCESSIBILITY_HINT)
|
||||
public void setAccessibilityHint(@Nonnull T view, String accessibilityHint) {
|
||||
public void setAccessibilityHint(@NonNull T view, String accessibilityHint) {
|
||||
view.setTag(R.id.accessibility_hint, accessibilityHint);
|
||||
updateViewContentDescription(view);
|
||||
}
|
||||
|
||||
@ReactProp(name = PROP_ACCESSIBILITY_ROLE)
|
||||
public void setAccessibilityRole(@Nonnull T view, @Nullable String accessibilityRole) {
|
||||
public void setAccessibilityRole(@NonNull T view, @Nullable String accessibilityRole) {
|
||||
if (accessibilityRole == null) {
|
||||
return;
|
||||
}
|
||||
@@ -158,7 +158,7 @@ public abstract class BaseViewManager<T extends View, C extends LayoutShadowNode
|
||||
}
|
||||
|
||||
@ReactProp(name = PROP_ACCESSIBILITY_STATES)
|
||||
public void setViewStates(@Nonnull T view, @Nullable ReadableArray accessibilityStates) {
|
||||
public void setViewStates(@NonNull T view, @Nullable ReadableArray accessibilityStates) {
|
||||
boolean shouldUpdateContentDescription =
|
||||
view.getTag(R.id.accessibility_states) != null && accessibilityStates == null;
|
||||
view.setTag(R.id.accessibility_states, accessibilityStates);
|
||||
@@ -183,7 +183,7 @@ public abstract class BaseViewManager<T extends View, C extends LayoutShadowNode
|
||||
}
|
||||
|
||||
@ReactProp(name = PROP_ACCESSIBILITY_STATE)
|
||||
public void setViewState(@Nonnull T view, @Nullable ReadableMap accessibilityState) {
|
||||
public void setViewState(@NonNull T view, @Nullable ReadableMap accessibilityState) {
|
||||
if (accessibilityState == null) {
|
||||
return;
|
||||
}
|
||||
@@ -208,7 +208,7 @@ public abstract class BaseViewManager<T extends View, C extends LayoutShadowNode
|
||||
}
|
||||
}
|
||||
|
||||
private void updateViewContentDescription(@Nonnull T view) {
|
||||
private void updateViewContentDescription(@NonNull T view) {
|
||||
final String accessibilityLabel = (String) view.getTag(R.id.accessibility_label);
|
||||
final ReadableArray accessibilityStates =
|
||||
(ReadableArray) view.getTag(R.id.accessibility_states);
|
||||
@@ -268,7 +268,7 @@ public abstract class BaseViewManager<T extends View, C extends LayoutShadowNode
|
||||
|
||||
@ReactProp(name = PROP_IMPORTANT_FOR_ACCESSIBILITY)
|
||||
public void setImportantForAccessibility(
|
||||
@Nonnull T view, @Nullable String importantForAccessibility) {
|
||||
@NonNull T view, @Nullable String importantForAccessibility) {
|
||||
if (importantForAccessibility == null || importantForAccessibility.equals("auto")) {
|
||||
ViewCompat.setImportantForAccessibility(view, ViewCompat.IMPORTANT_FOR_ACCESSIBILITY_AUTO);
|
||||
} else if (importantForAccessibility.equals("yes")) {
|
||||
@@ -283,36 +283,36 @@ public abstract class BaseViewManager<T extends View, C extends LayoutShadowNode
|
||||
|
||||
@Deprecated
|
||||
@ReactProp(name = PROP_ROTATION)
|
||||
public void setRotation(@Nonnull T view, float rotation) {
|
||||
public void setRotation(@NonNull T view, float rotation) {
|
||||
view.setRotation(rotation);
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
@ReactProp(name = PROP_SCALE_X, defaultFloat = 1f)
|
||||
public void setScaleX(@Nonnull T view, float scaleX) {
|
||||
public void setScaleX(@NonNull T view, float scaleX) {
|
||||
view.setScaleX(scaleX);
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
@ReactProp(name = PROP_SCALE_Y, defaultFloat = 1f)
|
||||
public void setScaleY(@Nonnull T view, float scaleY) {
|
||||
public void setScaleY(@NonNull T view, float scaleY) {
|
||||
view.setScaleY(scaleY);
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
@ReactProp(name = PROP_TRANSLATE_X, defaultFloat = 0f)
|
||||
public void setTranslateX(@Nonnull T view, float translateX) {
|
||||
public void setTranslateX(@NonNull T view, float translateX) {
|
||||
view.setTranslationX(PixelUtil.toPixelFromDIP(translateX));
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
@ReactProp(name = PROP_TRANSLATE_Y, defaultFloat = 0f)
|
||||
public void setTranslateY(@Nonnull T view, float translateY) {
|
||||
public void setTranslateY(@NonNull T view, float translateY) {
|
||||
view.setTranslationY(PixelUtil.toPixelFromDIP(translateY));
|
||||
}
|
||||
|
||||
@ReactProp(name = PROP_ACCESSIBILITY_LIVE_REGION)
|
||||
public void setAccessibilityLiveRegion(@Nonnull T view, @Nullable String liveRegion) {
|
||||
public void setAccessibilityLiveRegion(@NonNull T view, @Nullable String liveRegion) {
|
||||
if (liveRegion == null || liveRegion.equals("none")) {
|
||||
ViewCompat.setAccessibilityLiveRegion(view, ViewCompat.ACCESSIBILITY_LIVE_REGION_NONE);
|
||||
} else if (liveRegion.equals("polite")) {
|
||||
@@ -322,8 +322,7 @@ public abstract class BaseViewManager<T extends View, C extends LayoutShadowNode
|
||||
}
|
||||
}
|
||||
|
||||
private static void setTransformProperty(@Nonnull View view, ReadableArray transforms) {
|
||||
sMatrixDecompositionContext.reset();
|
||||
private static void setTransformProperty(@NonNull View view, ReadableArray transforms) {
|
||||
TransformHelper.processTransform(transforms, sTransformDecompositionArray);
|
||||
MatrixMathHelper.decomposeMatrix(sTransformDecompositionArray, sMatrixDecompositionContext);
|
||||
view.setTranslationX(
|
||||
@@ -360,7 +359,7 @@ public abstract class BaseViewManager<T extends View, C extends LayoutShadowNode
|
||||
}
|
||||
}
|
||||
|
||||
private static void resetTransformProperty(@Nonnull View view) {
|
||||
private static void resetTransformProperty(@NonNull View view) {
|
||||
view.setTranslationX(PixelUtil.toPixelFromDIP(0));
|
||||
view.setTranslationY(PixelUtil.toPixelFromDIP(0));
|
||||
view.setRotation(0);
|
||||
@@ -371,12 +370,12 @@ public abstract class BaseViewManager<T extends View, C extends LayoutShadowNode
|
||||
view.setCameraDistance(0);
|
||||
}
|
||||
|
||||
private void updateViewAccessibility(@Nonnull T view) {
|
||||
private void updateViewAccessibility(@NonNull T view) {
|
||||
ReactAccessibilityDelegate.setDelegate(view);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onAfterUpdateTransaction(@Nonnull T view) {
|
||||
protected void onAfterUpdateTransaction(@NonNull T view) {
|
||||
super.onAfterUpdateTransaction(view);
|
||||
updateViewAccessibility(view);
|
||||
}
|
||||
|
||||
@@ -11,13 +11,13 @@ import android.os.Build;
|
||||
import android.util.DisplayMetrics;
|
||||
import android.view.Display;
|
||||
import android.view.WindowManager;
|
||||
import androidx.annotation.Nullable;
|
||||
import com.facebook.infer.annotation.Assertions;
|
||||
import com.facebook.react.bridge.WritableNativeMap;
|
||||
import java.lang.reflect.InvocationTargetException;
|
||||
import java.lang.reflect.Method;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
/**
|
||||
* Holds an instance of the current DisplayMetrics so we don't have to thread it through all the
|
||||
|
||||
@@ -5,6 +5,7 @@
|
||||
|
||||
package com.facebook.react.uimanager;
|
||||
|
||||
import androidx.annotation.Nullable;
|
||||
import com.facebook.react.bridge.Dynamic;
|
||||
import com.facebook.react.bridge.JSApplicationIllegalArgumentException;
|
||||
import com.facebook.react.bridge.ReadableType;
|
||||
@@ -20,7 +21,6 @@ import com.facebook.yoga.YogaOverflow;
|
||||
import com.facebook.yoga.YogaPositionType;
|
||||
import com.facebook.yoga.YogaUnit;
|
||||
import com.facebook.yoga.YogaWrap;
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
/**
|
||||
* Supply setters for base view layout properties such as width, height, flex properties, borders,
|
||||
|
||||
+1
-1
@@ -16,6 +16,7 @@ import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.view.ViewParent;
|
||||
import android.widget.PopupMenu;
|
||||
import androidx.annotation.Nullable;
|
||||
import com.facebook.common.logging.FLog;
|
||||
import com.facebook.react.R;
|
||||
import com.facebook.react.bridge.Callback;
|
||||
@@ -32,7 +33,6 @@ import com.facebook.react.uimanager.layoutanimation.LayoutAnimationListener;
|
||||
import com.facebook.systrace.Systrace;
|
||||
import com.facebook.systrace.SystraceMessage;
|
||||
import java.util.Arrays;
|
||||
import javax.annotation.Nullable;
|
||||
import javax.annotation.concurrent.NotThreadSafe;
|
||||
|
||||
/**
|
||||
|
||||
+1
-1
@@ -7,10 +7,10 @@
|
||||
package com.facebook.react.uimanager;
|
||||
|
||||
import android.util.SparseBooleanArray;
|
||||
import androidx.annotation.Nullable;
|
||||
import com.facebook.infer.annotation.Assertions;
|
||||
import com.facebook.react.bridge.ReadableArray;
|
||||
import com.facebook.react.bridge.ReadableMapKeySetIterator;
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
/**
|
||||
* Class responsible for optimizing the native view hierarchy while still respecting the final UI
|
||||
|
||||
+1
-1
@@ -11,6 +11,7 @@ import android.text.SpannableString;
|
||||
import android.text.style.URLSpan;
|
||||
import android.util.Log;
|
||||
import android.view.View;
|
||||
import androidx.annotation.Nullable;
|
||||
import androidx.core.view.AccessibilityDelegateCompat;
|
||||
import androidx.core.view.ViewCompat;
|
||||
import androidx.core.view.accessibility.AccessibilityNodeInfoCompat;
|
||||
@@ -26,7 +27,6 @@ import com.facebook.react.bridge.ReadableType;
|
||||
import com.facebook.react.bridge.WritableMap;
|
||||
import com.facebook.react.uimanager.events.RCTEventEmitter;
|
||||
import java.util.HashMap;
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
/**
|
||||
* Utility class that handles the addition of a "role" for accessibility to either a View or
|
||||
|
||||
@@ -8,8 +8,8 @@ package com.facebook.react.uimanager;
|
||||
|
||||
import android.os.Bundle;
|
||||
import android.view.ViewGroup;
|
||||
import androidx.annotation.Nullable;
|
||||
import com.facebook.react.uimanager.common.UIManagerType;
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
/** Interface for the root native view of a React native application */
|
||||
public interface ReactRoot {
|
||||
|
||||
@@ -6,6 +6,7 @@
|
||||
*/
|
||||
package com.facebook.react.uimanager;
|
||||
|
||||
import androidx.annotation.Nullable;
|
||||
import com.facebook.yoga.YogaAlign;
|
||||
import com.facebook.yoga.YogaBaselineFunction;
|
||||
import com.facebook.yoga.YogaDirection;
|
||||
@@ -18,7 +19,6 @@ import com.facebook.yoga.YogaOverflow;
|
||||
import com.facebook.yoga.YogaPositionType;
|
||||
import com.facebook.yoga.YogaValue;
|
||||
import com.facebook.yoga.YogaWrap;
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
/**
|
||||
* Base node class for representing virtual tree of React nodes. Shadow nodes are used primarily for
|
||||
|
||||
@@ -6,6 +6,7 @@
|
||||
*/
|
||||
package com.facebook.react.uimanager;
|
||||
|
||||
import androidx.annotation.Nullable;
|
||||
import com.facebook.infer.annotation.Assertions;
|
||||
import com.facebook.react.uimanager.annotations.ReactPropertyHolder;
|
||||
import com.facebook.yoga.YogaAlign;
|
||||
@@ -25,7 +26,6 @@ import com.facebook.yoga.YogaValue;
|
||||
import com.facebook.yoga.YogaWrap;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
/**
|
||||
* Base node class for representing virtual tree of React nodes. Shadow nodes are used primarily for
|
||||
|
||||
@@ -7,11 +7,11 @@
|
||||
package com.facebook.react.uimanager;
|
||||
|
||||
import android.view.View;
|
||||
import androidx.annotation.Nullable;
|
||||
import com.facebook.react.bridge.Dynamic;
|
||||
import com.facebook.react.bridge.ReadableArray;
|
||||
import com.facebook.react.bridge.ReadableMap;
|
||||
import java.util.Map;
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
/**
|
||||
* Wrapper for {@link ReadableMap} which should be used for styles property map. It extends some of
|
||||
|
||||
@@ -8,10 +8,10 @@ package com.facebook.react.uimanager;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.content.Context;
|
||||
import androidx.annotation.Nullable;
|
||||
import com.facebook.react.bridge.LifecycleEventListener;
|
||||
import com.facebook.react.bridge.ReactApplicationContext;
|
||||
import com.facebook.react.bridge.ReactContext;
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
/**
|
||||
* Wraps {@link ReactContext} with the base {@link Context} passed into the constructor. It provides
|
||||
|
||||
@@ -12,10 +12,10 @@ import android.graphics.Rect;
|
||||
import android.view.MotionEvent;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import androidx.annotation.Nullable;
|
||||
import com.facebook.react.bridge.JSApplicationIllegalArgumentException;
|
||||
import com.facebook.react.bridge.UiThreadUtil;
|
||||
import com.facebook.react.touch.ReactHitSlopView;
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
/**
|
||||
* Class responsible for identifying which react view should handle a given {@link MotionEvent}. It
|
||||
|
||||
@@ -9,6 +9,7 @@ package com.facebook.react.uimanager;
|
||||
import android.os.SystemClock;
|
||||
import android.view.View;
|
||||
import android.view.View.MeasureSpec;
|
||||
import androidx.annotation.Nullable;
|
||||
import com.facebook.common.logging.FLog;
|
||||
import com.facebook.infer.annotation.Assertions;
|
||||
import com.facebook.react.bridge.Arguments;
|
||||
@@ -29,7 +30,6 @@ import com.facebook.yoga.YogaDirection;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
/**
|
||||
* A class that is used to receive React commands from JS and translate them into a shadow node
|
||||
|
||||
@@ -16,6 +16,7 @@ import android.content.Context;
|
||||
import android.content.res.Configuration;
|
||||
import android.media.AudioManager;
|
||||
import android.view.View;
|
||||
import androidx.annotation.Nullable;
|
||||
import androidx.collection.ArrayMap;
|
||||
import com.facebook.common.logging.FLog;
|
||||
import com.facebook.debug.holder.PrinterHolder;
|
||||
@@ -49,7 +50,6 @@ import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
/**
|
||||
* Native module to allow JS to create and update native Views.
|
||||
|
||||
+1
-1
@@ -8,12 +8,12 @@ package com.facebook.react.uimanager;
|
||||
|
||||
import static com.facebook.systrace.Systrace.TRACE_TAG_REACT_JAVA_BRIDGE;
|
||||
|
||||
import androidx.annotation.Nullable;
|
||||
import com.facebook.react.common.MapBuilder;
|
||||
import com.facebook.react.config.ReactFeatureFlags;
|
||||
import com.facebook.systrace.SystraceMessage;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
/**
|
||||
* Helps generate constants map for {@link UIManagerModule} by collecting and merging constants from
|
||||
|
||||
@@ -8,6 +8,7 @@ package com.facebook.react.uimanager;
|
||||
|
||||
import android.os.SystemClock;
|
||||
import android.view.View;
|
||||
import androidx.annotation.Nullable;
|
||||
import com.facebook.common.logging.FLog;
|
||||
import com.facebook.react.bridge.Callback;
|
||||
import com.facebook.react.bridge.GuardedRunnable;
|
||||
@@ -26,7 +27,6 @@ import java.util.ArrayDeque;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import javax.annotation.Nullable;
|
||||
import javax.annotation.concurrent.GuardedBy;
|
||||
|
||||
/**
|
||||
|
||||
+1
-1
@@ -8,10 +8,10 @@ package com.facebook.react.uimanager;
|
||||
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import androidx.annotation.Nullable;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.Comparator;
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
/** Helper to handle implementing ViewGroups with custom drawing order based on z-index. */
|
||||
public class ViewGroupDrawingOrderHelper {
|
||||
|
||||
@@ -8,9 +8,9 @@ package com.facebook.react.uimanager;
|
||||
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import androidx.annotation.Nullable;
|
||||
import java.util.List;
|
||||
import java.util.WeakHashMap;
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
/** Class providing children management API for view managers of classes extending ViewGroup. */
|
||||
public abstract class ViewGroupManager<T extends ViewGroup>
|
||||
|
||||
@@ -8,6 +8,8 @@ package com.facebook.react.uimanager;
|
||||
|
||||
import android.content.Context;
|
||||
import android.view.View;
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
import com.facebook.react.bridge.BaseJavaModule;
|
||||
import com.facebook.react.bridge.ReactApplicationContext;
|
||||
import com.facebook.react.bridge.ReadableArray;
|
||||
@@ -19,8 +21,6 @@ import com.facebook.react.uimanager.annotations.ReactPropGroup;
|
||||
import com.facebook.react.uimanager.annotations.ReactPropertyHolder;
|
||||
import com.facebook.yoga.YogaMeasureMode;
|
||||
import java.util.Map;
|
||||
import javax.annotation.Nonnull;
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
/**
|
||||
* Class responsible for knowing how to create and update catalyst Views of a given type. It is also
|
||||
@@ -39,20 +39,20 @@ public abstract class ViewManager<T extends View, C extends ReactShadowNode>
|
||||
* @param props
|
||||
* @param stateWrapper
|
||||
*/
|
||||
public void updateProperties(@Nonnull T viewToUpdate, ReactStylesDiffMap props) {
|
||||
public void updateProperties(@NonNull T viewToUpdate, ReactStylesDiffMap props) {
|
||||
ViewManagerPropertyUpdater.updateProps(this, viewToUpdate, props);
|
||||
onAfterUpdateTransaction(viewToUpdate);
|
||||
}
|
||||
|
||||
/** Creates a view and installs event emitters on it. */
|
||||
private final @Nonnull T createView(
|
||||
@Nonnull ThemedReactContext reactContext, JSResponderHandler jsResponderHandler) {
|
||||
private final @NonNull T createView(
|
||||
@NonNull ThemedReactContext reactContext, JSResponderHandler jsResponderHandler) {
|
||||
return createView(reactContext, null, null, jsResponderHandler);
|
||||
}
|
||||
|
||||
/** Creates a view with knowledge of props. */
|
||||
public @Nonnull T createView(
|
||||
@Nonnull ThemedReactContext reactContext,
|
||||
public @NonNull T createView(
|
||||
@NonNull ThemedReactContext reactContext,
|
||||
@Nullable ReactStylesDiffMap props,
|
||||
@Nullable StateWrapper stateWrapper,
|
||||
JSResponderHandler jsResponderHandler) {
|
||||
@@ -68,7 +68,7 @@ public abstract class ViewManager<T extends View, C extends ReactShadowNode>
|
||||
* @return the name of this view manager. This will be the name used to reference this view
|
||||
* manager from JavaScript in createReactNativeComponentClass.
|
||||
*/
|
||||
public abstract @Nonnull String getName();
|
||||
public abstract @NonNull String getName();
|
||||
|
||||
/**
|
||||
* This method should return a subclass of {@link ReactShadowNode} which will be then used for
|
||||
@@ -79,7 +79,7 @@ public abstract class ViewManager<T extends View, C extends ReactShadowNode>
|
||||
throw new RuntimeException("ViewManager subclasses must implement createShadowNodeInstance()");
|
||||
}
|
||||
|
||||
public @Nonnull C createShadowNodeInstance(@Nonnull ReactApplicationContext context) {
|
||||
public @NonNull C createShadowNodeInstance(@NonNull ReactApplicationContext context) {
|
||||
return createShadowNodeInstance();
|
||||
}
|
||||
|
||||
@@ -100,7 +100,7 @@ public abstract class ViewManager<T extends View, C extends ReactShadowNode>
|
||||
*
|
||||
* @param reactContext
|
||||
*/
|
||||
protected abstract @Nonnull T createViewInstance(@Nonnull ThemedReactContext reactContext);
|
||||
protected abstract @NonNull T createViewInstance(@NonNull ThemedReactContext reactContext);
|
||||
|
||||
/**
|
||||
* Subclasses should return a new View instance of the proper type. This is an optional method
|
||||
@@ -109,8 +109,8 @@ public abstract class ViewManager<T extends View, C extends ReactShadowNode>
|
||||
*
|
||||
* @param reactContext
|
||||
*/
|
||||
protected @Nonnull T createViewInstance(
|
||||
@Nonnull ThemedReactContext reactContext,
|
||||
protected @NonNull T createViewInstance(
|
||||
@NonNull ThemedReactContext reactContext,
|
||||
@Nullable ReactStylesDiffMap initialProps,
|
||||
@Nullable StateWrapper stateWrapper) {
|
||||
T view = createViewInstance(reactContext);
|
||||
@@ -124,14 +124,14 @@ public abstract class ViewManager<T extends View, C extends ReactShadowNode>
|
||||
* Called when view is detached from view hierarchy and allows for some additional cleanup by the
|
||||
* {@link ViewManager} subclass.
|
||||
*/
|
||||
public void onDropViewInstance(@Nonnull T view) {}
|
||||
public void onDropViewInstance(@NonNull T view) {}
|
||||
|
||||
/**
|
||||
* Subclasses can override this method to install custom event emitters on the given View. You
|
||||
* might want to override this method if your view needs to emit events besides basic touch events
|
||||
* to JS (e.g. scroll events).
|
||||
*/
|
||||
protected void addEventEmitters(@Nonnull ThemedReactContext reactContext, @Nonnull T view) {}
|
||||
protected void addEventEmitters(@NonNull ThemedReactContext reactContext, @NonNull T view) {}
|
||||
|
||||
/**
|
||||
* Callback that will be triggered after all properties are updated in current update transaction
|
||||
@@ -139,7 +139,7 @@ public abstract class ViewManager<T extends View, C extends ReactShadowNode>
|
||||
* you want to override this method you should call super.onAfterUpdateTransaction from it as the
|
||||
* parent class of the ViewManager may rely on callback being executed.
|
||||
*/
|
||||
protected void onAfterUpdateTransaction(@Nonnull T view) {}
|
||||
protected void onAfterUpdateTransaction(@NonNull T view) {}
|
||||
|
||||
/**
|
||||
* Subclasses can implement this method to receive an optional extra data enqueued from the
|
||||
@@ -152,7 +152,7 @@ public abstract class ViewManager<T extends View, C extends ReactShadowNode>
|
||||
*
|
||||
* <p>TODO(7247021): Replace updateExtraData with generic update props mechanism after D2086999
|
||||
*/
|
||||
public abstract void updateExtraData(@Nonnull T root, Object extraData);
|
||||
public abstract void updateExtraData(@NonNull T root, Object extraData);
|
||||
|
||||
/**
|
||||
* Subclasses may use this method to receive events/commands directly from JS through the {@link
|
||||
@@ -166,7 +166,7 @@ public abstract class ViewManager<T extends View, C extends ReactShadowNode>
|
||||
* @param args optional arguments for the command
|
||||
*/
|
||||
@Deprecated
|
||||
public void receiveCommand(@Nonnull T root, int commandId, @Nullable ReadableArray args) {}
|
||||
public void receiveCommand(@NonNull T root, int commandId, @Nullable ReadableArray args) {}
|
||||
|
||||
/**
|
||||
* Subclasses may use this method to receive events/commands directly from JS through the {@link
|
||||
@@ -177,7 +177,7 @@ public abstract class ViewManager<T extends View, C extends ReactShadowNode>
|
||||
* @param commandId code of the command
|
||||
* @param args optional arguments for the command
|
||||
*/
|
||||
public void receiveCommand(@Nonnull T root, String commandId, @Nullable ReadableArray args) {}
|
||||
public void receiveCommand(@NonNull T root, String commandId, @Nullable ReadableArray args) {}
|
||||
|
||||
/**
|
||||
* Subclasses of {@link ViewManager} that expect to receive commands through {@link
|
||||
@@ -244,7 +244,7 @@ public abstract class ViewManager<T extends View, C extends ReactShadowNode>
|
||||
}
|
||||
|
||||
public @Nullable Object updateLocalData(
|
||||
@Nonnull T view, ReactStylesDiffMap props, ReactStylesDiffMap localData) {
|
||||
@NonNull T view, ReactStylesDiffMap props, ReactStylesDiffMap localData) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -253,7 +253,7 @@ public abstract class ViewManager<T extends View, C extends ReactShadowNode>
|
||||
* this component type.
|
||||
*/
|
||||
public @Nullable Object updateState(
|
||||
@Nonnull T view, ReactStylesDiffMap props, StateWrapper stateWrapper) {
|
||||
@NonNull T view, ReactStylesDiffMap props, StateWrapper stateWrapper) {
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
@@ -6,10 +6,10 @@
|
||||
*/
|
||||
package com.facebook.react.uimanager;
|
||||
|
||||
import androidx.annotation.Nullable;
|
||||
import com.facebook.react.common.MapBuilder;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
/**
|
||||
* Class that stores the mapping between native view name used in JS and the corresponding instance
|
||||
|
||||
+1
-1
@@ -6,6 +6,7 @@
|
||||
package com.facebook.react.uimanager;
|
||||
|
||||
import android.view.View;
|
||||
import androidx.annotation.Nullable;
|
||||
import com.facebook.common.logging.FLog;
|
||||
import com.facebook.react.bridge.Dynamic;
|
||||
import com.facebook.react.bridge.DynamicFromObject;
|
||||
@@ -18,7 +19,6 @@ import java.lang.reflect.Method;
|
||||
import java.util.Arrays;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
/**
|
||||
* This class is responsible for holding view manager property setters and is used in a process of
|
||||
|
||||
@@ -3,11 +3,13 @@ load("//tools/build_defs/oss:rn_defs.bzl", "react_native_dep", "rn_android_libra
|
||||
rn_android_library(
|
||||
name = "annotations",
|
||||
srcs = glob(["*.java"]),
|
||||
is_androidx = True,
|
||||
required_for_source_only_abi = True,
|
||||
visibility = [
|
||||
"PUBLIC",
|
||||
],
|
||||
deps = [
|
||||
react_native_dep("third-party/android/androidx:annotation"),
|
||||
react_native_dep("third-party/java/jsr-305:jsr-305"),
|
||||
],
|
||||
)
|
||||
|
||||
@@ -7,10 +7,10 @@ package com.facebook.react.uimanager.annotations;
|
||||
|
||||
import static java.lang.annotation.RetentionPolicy.RUNTIME;
|
||||
|
||||
import androidx.annotation.Nullable;
|
||||
import java.lang.annotation.ElementType;
|
||||
import java.lang.annotation.Retention;
|
||||
import java.lang.annotation.Target;
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
/**
|
||||
* Use this annotation to annotate properties of native views that should be exposed to JS. This
|
||||
|
||||
+1
-1
@@ -7,10 +7,10 @@ package com.facebook.react.uimanager.annotations;
|
||||
|
||||
import static java.lang.annotation.RetentionPolicy.RUNTIME;
|
||||
|
||||
import androidx.annotation.Nullable;
|
||||
import java.lang.annotation.ElementType;
|
||||
import java.lang.annotation.Retention;
|
||||
import java.lang.annotation.Target;
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
/**
|
||||
* Use this annotation to annotate group of properties of native views that should be exposed to JS.
|
||||
|
||||
@@ -6,10 +6,10 @@
|
||||
*/
|
||||
package com.facebook.react.uimanager.events;
|
||||
|
||||
import androidx.annotation.Nullable;
|
||||
import com.facebook.react.bridge.JavaScriptModule;
|
||||
import com.facebook.react.bridge.WritableArray;
|
||||
import com.facebook.react.bridge.WritableMap;
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
public interface RCTEventEmitter extends JavaScriptModule {
|
||||
void receiveEvent(int targetTag, String eventName, @Nullable WritableMap event);
|
||||
|
||||
+1
-1
@@ -9,13 +9,13 @@ package com.facebook.react.uimanager.events;
|
||||
import static com.facebook.react.uimanager.events.TouchesHelper.TARGET_KEY;
|
||||
|
||||
import android.util.SparseArray;
|
||||
import androidx.annotation.Nullable;
|
||||
import com.facebook.infer.annotation.Assertions;
|
||||
import com.facebook.react.bridge.ReactApplicationContext;
|
||||
import com.facebook.react.bridge.WritableArray;
|
||||
import com.facebook.react.bridge.WritableMap;
|
||||
import com.facebook.react.uimanager.common.UIManagerType;
|
||||
import com.facebook.react.uimanager.common.ViewUtil;
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
public class ReactEventEmitter implements RCTEventEmitter {
|
||||
|
||||
|
||||
@@ -7,10 +7,10 @@
|
||||
package com.facebook.react.uimanager.events;
|
||||
|
||||
import android.view.MotionEvent;
|
||||
import androidx.annotation.Nullable;
|
||||
import androidx.core.util.Pools;
|
||||
import com.facebook.infer.annotation.Assertions;
|
||||
import com.facebook.react.bridge.SoftAssertions;
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
/**
|
||||
* An event representing the start, end or movement of a touch. Corresponds to a single {@link
|
||||
|
||||
+1
-1
@@ -13,11 +13,11 @@ import android.view.animation.BaseInterpolator;
|
||||
import android.view.animation.DecelerateInterpolator;
|
||||
import android.view.animation.Interpolator;
|
||||
import android.view.animation.LinearInterpolator;
|
||||
import androidx.annotation.Nullable;
|
||||
import com.facebook.react.bridge.ReadableMap;
|
||||
import com.facebook.react.common.MapBuilder;
|
||||
import com.facebook.react.uimanager.IllegalViewOperationException;
|
||||
import java.util.Map;
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
/**
|
||||
* Class responsible for parsing and converting layout animation data into native {@link Animation}
|
||||
|
||||
+1
-1
@@ -11,10 +11,10 @@ import android.util.SparseArray;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.view.animation.Animation;
|
||||
import androidx.annotation.Nullable;
|
||||
import com.facebook.react.bridge.Callback;
|
||||
import com.facebook.react.bridge.ReadableMap;
|
||||
import com.facebook.react.bridge.UiThreadUtil;
|
||||
import javax.annotation.Nullable;
|
||||
import javax.annotation.concurrent.NotThreadSafe;
|
||||
|
||||
/**
|
||||
|
||||
+1
-1
@@ -8,7 +8,7 @@ package com.facebook.react.uimanager.layoutanimation;
|
||||
import android.view.View;
|
||||
import android.view.animation.Animation;
|
||||
import android.view.animation.TranslateAnimation;
|
||||
import javax.annotation.Nullable;
|
||||
import androidx.annotation.Nullable;
|
||||
|
||||
/**
|
||||
* Class responsible for handling layout update animation, applied to view whenever a valid config
|
||||
|
||||
Reference in New Issue
Block a user