mirror of
https://github.com/facebook/react-native.git
synced 2025-11-01 09:14:26 +00:00
Update PointerEvents static method to reduce duplication
Summary: This diff updated `PointerEvents` enum to reduce duplication for null checks on pointer events string. Changelog: [Internal] Reviewed By: javache Differential Revision: D33717223 fbshipit-source-id: ff542a05240393416d85651ca08cd55136eb79a4
This commit is contained in:
committed by
Facebook GitHub Bot
parent
d6db5c5464
commit
67355f6c74
@@ -29,7 +29,11 @@ public enum PointerEvents {
|
||||
;
|
||||
|
||||
public static PointerEvents parsePointerEvents(String pointerEventsStr) {
|
||||
return PointerEvents.valueOf(pointerEventsStr.toUpperCase(Locale.US).replace("-", "_"));
|
||||
if (pointerEventsStr == null) {
|
||||
return PointerEvents.AUTO;
|
||||
} else {
|
||||
return PointerEvents.valueOf(pointerEventsStr.toUpperCase(Locale.US).replace("-", "_"));
|
||||
}
|
||||
}
|
||||
|
||||
public static boolean canBeTouchTarget(PointerEvents pointerEvents) {
|
||||
|
||||
+1
-5
@@ -325,10 +325,6 @@ public class ReactHorizontalScrollViewManager extends ViewGroupManager<ReactHori
|
||||
|
||||
@ReactProp(name = ViewProps.POINTER_EVENTS)
|
||||
public void setPointerEvents(ReactHorizontalScrollView view, @Nullable String pointerEventsStr) {
|
||||
if (pointerEventsStr == null) {
|
||||
view.setPointerEvents(PointerEvents.AUTO);
|
||||
} else {
|
||||
view.setPointerEvents(PointerEvents.parsePointerEvents(pointerEventsStr));
|
||||
}
|
||||
view.setPointerEvents(PointerEvents.parsePointerEvents(pointerEventsStr));
|
||||
}
|
||||
}
|
||||
|
||||
+1
-5
@@ -367,10 +367,6 @@ public class ReactScrollViewManager extends ViewGroupManager<ReactScrollView>
|
||||
|
||||
@ReactProp(name = ViewProps.POINTER_EVENTS)
|
||||
public void setPointerEvents(ReactScrollView view, @Nullable String pointerEventsStr) {
|
||||
if (pointerEventsStr == null) {
|
||||
view.setPointerEvents(PointerEvents.AUTO);
|
||||
} else {
|
||||
view.setPointerEvents(PointerEvents.parsePointerEvents(pointerEventsStr));
|
||||
}
|
||||
view.setPointerEvents(PointerEvents.parsePointerEvents(pointerEventsStr));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -31,7 +31,6 @@ import com.facebook.react.uimanager.annotations.ReactProp;
|
||||
import com.facebook.react.uimanager.annotations.ReactPropGroup;
|
||||
import com.facebook.react.uimanager.events.EventDispatcher;
|
||||
import com.facebook.yoga.YogaConstants;
|
||||
import java.util.Locale;
|
||||
import java.util.Map;
|
||||
|
||||
/** View manager for AndroidViews (plain React Views). */
|
||||
@@ -161,13 +160,7 @@ public class ReactViewManager extends ReactClippingViewManager<ReactViewGroup> {
|
||||
|
||||
@ReactProp(name = ViewProps.POINTER_EVENTS)
|
||||
public void setPointerEvents(ReactViewGroup view, @Nullable String pointerEventsStr) {
|
||||
if (pointerEventsStr == null) {
|
||||
view.setPointerEvents(PointerEvents.AUTO);
|
||||
} else {
|
||||
PointerEvents pointerEvents =
|
||||
PointerEvents.valueOf(pointerEventsStr.toUpperCase(Locale.US).replace("-", "_"));
|
||||
view.setPointerEvents(pointerEvents);
|
||||
}
|
||||
view.setPointerEvents(PointerEvents.parsePointerEvents(pointerEventsStr));
|
||||
}
|
||||
|
||||
@ReactProp(name = "nativeBackgroundAndroid")
|
||||
|
||||
Reference in New Issue
Block a user