mirror of
https://github.com/facebook/react-native.git
synced 2025-11-01 09:14:26 +00:00
Remove warnings in some RN Android classes
Summary: I've been analyzing some issue in RN Android code and I noticed some warnings to clean up Reviewed By: ejanzer Differential Revision: D16060522 fbshipit-source-id: 327fa86c24c7dd67ac2376bbd2f0ca4339f106d1
This commit is contained in:
committed by
Facebook Github Bot
parent
d07ab35bfb
commit
a679f592cd
@@ -22,6 +22,7 @@ import com.facebook.react.uimanager.annotations.ReactProp;
|
||||
import com.facebook.react.uimanager.util.ReactFindViewUtil;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import javax.annotation.Nonnull;
|
||||
import javax.annotation.Nullable;
|
||||
@@ -66,7 +67,7 @@ public abstract class BaseViewManager<T extends View, C extends LayoutShadowNode
|
||||
new MatrixMathHelper.MatrixDecompositionContext();
|
||||
private static double[] sTransformDecompositionArray = new double[16];
|
||||
|
||||
public static final HashMap<String, Integer> sStateDescription = new HashMap<String, Integer>();
|
||||
public static final Map<String, Integer> sStateDescription = new HashMap<>();
|
||||
|
||||
static {
|
||||
sStateDescription.put("busy", R.string.state_busy_description);
|
||||
@@ -112,7 +113,7 @@ public abstract class BaseViewManager<T extends View, C extends LayoutShadowNode
|
||||
int integerZIndex = Math.round(zIndex);
|
||||
ViewGroupManager.setViewZIndex(view, integerZIndex);
|
||||
ViewParent parent = view.getParent();
|
||||
if (parent != null && parent instanceof ReactZIndexedViewGroup) {
|
||||
if (parent instanceof ReactZIndexedViewGroup) {
|
||||
((ReactZIndexedViewGroup) parent).updateDrawingOrder();
|
||||
}
|
||||
}
|
||||
@@ -169,9 +170,9 @@ public abstract class BaseViewManager<T extends View, C extends LayoutShadowNode
|
||||
if (sStateDescription.containsKey(state)) {
|
||||
shouldUpdateContentDescription = true;
|
||||
}
|
||||
if (state.equals("selected")) {
|
||||
if ("selected".equals(state)) {
|
||||
view.setSelected(true);
|
||||
} else if (state.equals("disabled")) {
|
||||
} else if ("disabled".equals(state)) {
|
||||
view.setEnabled(false);
|
||||
}
|
||||
}
|
||||
@@ -213,7 +214,7 @@ public abstract class BaseViewManager<T extends View, C extends LayoutShadowNode
|
||||
(ReadableArray) view.getTag(R.id.accessibility_states);
|
||||
final ReadableMap accessibilityState = (ReadableMap) view.getTag(R.id.accessibility_state);
|
||||
final String accessibilityHint = (String) view.getTag(R.id.accessibility_hint);
|
||||
final ArrayList<String> contentDescription = new ArrayList<String>();
|
||||
final List<String> contentDescription = new ArrayList<>();
|
||||
if (accessibilityLabel != null) {
|
||||
contentDescription.add(accessibilityLabel);
|
||||
}
|
||||
|
||||
+1
-3
@@ -32,8 +32,6 @@ import com.facebook.react.uimanager.layoutanimation.LayoutAnimationListener;
|
||||
import com.facebook.systrace.Systrace;
|
||||
import com.facebook.systrace.SystraceMessage;
|
||||
import java.util.Arrays;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import javax.annotation.Nullable;
|
||||
import javax.annotation.concurrent.NotThreadSafe;
|
||||
|
||||
@@ -74,7 +72,7 @@ public class NativeViewHierarchyManager {
|
||||
private final JSResponderHandler mJSResponderHandler = new JSResponderHandler();
|
||||
private final RootViewManager mRootViewManager;
|
||||
private final LayoutAnimationController mLayoutAnimator = new LayoutAnimationController();
|
||||
private final Map<Integer, SparseIntArray> mTagsToPendingIndicesToDelete = new HashMap<>();
|
||||
private final SparseArray<SparseIntArray> mTagsToPendingIndicesToDelete = new SparseArray<>();
|
||||
private final int[] mDroppedViewArray = new int[100];
|
||||
|
||||
private boolean mLayoutAnimationEnabled;
|
||||
|
||||
@@ -171,7 +171,7 @@ public abstract class ViewManager<T extends View, C extends ReactShadowNode>
|
||||
/**
|
||||
* Subclasses may use this method to receive events/commands directly from JS through the {@link
|
||||
* UIManager}. Good example of such a command would be {@code scrollTo} request with coordinates
|
||||
* for a {@link ScrollView} instance.
|
||||
* for a {@link ReactScrollView} instance.
|
||||
*
|
||||
* @param root View instance that should receive the command
|
||||
* @param commandId code of the command
|
||||
|
||||
@@ -10,6 +10,8 @@ import android.annotation.TargetApi;
|
||||
import android.graphics.Rect;
|
||||
import android.os.Build;
|
||||
import android.view.View;
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
import com.facebook.react.bridge.JSApplicationIllegalArgumentException;
|
||||
import com.facebook.react.bridge.ReactContext;
|
||||
import com.facebook.react.bridge.ReadableArray;
|
||||
@@ -30,7 +32,6 @@ import com.facebook.react.uimanager.events.EventDispatcher;
|
||||
import com.facebook.yoga.YogaConstants;
|
||||
import java.util.Locale;
|
||||
import java.util.Map;
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
/** View manager for AndroidViews (plain React Views). */
|
||||
@ReactModule(name = ReactViewManager.REACT_CLASS)
|
||||
@@ -49,6 +50,7 @@ public class ReactViewManager extends ViewGroupManager<ReactViewGroup> {
|
||||
};
|
||||
private static final int CMD_HOTSPOT_UPDATE = 1;
|
||||
private static final int CMD_SET_PRESSED = 2;
|
||||
private static final String HOTSPOT_UPDATE_KEY = "hotspotUpdate";
|
||||
|
||||
@ReactProp(name = "accessible")
|
||||
public void setAccessible(ReactViewGroup view, boolean accessible) {
|
||||
@@ -267,12 +269,12 @@ public class ReactViewManager extends ViewGroupManager<ReactViewGroup> {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setOpacity(ReactViewGroup view, float opacity) {
|
||||
public void setOpacity(@NonNull ReactViewGroup view, float opacity) {
|
||||
view.setOpacityIfPossible(opacity);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setTransform(ReactViewGroup view, ReadableArray matrix) {
|
||||
public void setTransform(@NonNull ReactViewGroup view, @Nullable ReadableArray matrix) {
|
||||
super.setTransform(view, matrix);
|
||||
view.setBackfaceVisibilityDependantOpacity();
|
||||
}
|
||||
@@ -289,7 +291,7 @@ public class ReactViewManager extends ViewGroupManager<ReactViewGroup> {
|
||||
|
||||
@Override
|
||||
public Map<String, Integer> getCommandsMap() {
|
||||
return MapBuilder.of("hotspotUpdate", CMD_HOTSPOT_UPDATE, "setPressed", CMD_SET_PRESSED);
|
||||
return MapBuilder.of(HOTSPOT_UPDATE_KEY, CMD_HOTSPOT_UPDATE, "setPressed", CMD_SET_PRESSED);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -311,7 +313,7 @@ public class ReactViewManager extends ViewGroupManager<ReactViewGroup> {
|
||||
@Override
|
||||
public void receiveCommand(ReactViewGroup root, String commandId, @Nullable ReadableArray args) {
|
||||
switch (commandId) {
|
||||
case "hotspotUpdate":
|
||||
case HOTSPOT_UPDATE_KEY:
|
||||
{
|
||||
handleHotspotUpdate(root, args);
|
||||
break;
|
||||
|
||||
Reference in New Issue
Block a user