Commit 91e2f71
authored
[Android] Suppress
## Description
When building app with `react-native` 0.78.1, _**Gesture Handler**_ build fails with the following error message:
```
react-native-gesture-handler/android/fabric/src/main/java/com/swmansion/gesturehandler/ReactContextExtensions.kt:10:
Error: Must be one of: UIManagerType.DEFAULT, UIManagerType.FABRIC [WrongConstant]
val fabricUIManager = UIManagerHelper.getUIManager(this, UIManagerType.FABRIC) as FabricUIManager
```
As stated in the error above, constant passed to `getUIManager` should be either `UIManagerType.DEFAULT` or `UIManagerType.FABRIC`, but this condition is clearly met. In that case, I've added `SuppressLint` annotation to get rid of the error.
Fixes #3464
## Test plan
Function above is called in specific condition, i.e. if `onGestureEvent` is `Animated.Event`. In order to check if we can suppress this error without problems, I've used the following code:
<details>
<summary>Test code</summary>
```jsx
import React, {useRef} from 'react';
import {View, Animated, StyleSheet} from 'react-native';
import {
PanGestureHandler,
GestureHandlerRootView,
State,
} from 'react-native-gesture-handler';
export default function App() {
const translateX = useRef(new Animated.Value(0)).current;
const translateY = useRef(new Animated.Value(0)).current;
const onGestureEvent = Animated.event(
[{nativeEvent: {translationX: translateX, translationY: translateY}}],
{useNativeDriver: true},
);
const onHandlerStateChange = event => {
if (event.nativeEvent.state === State.END) {
Animated.spring(translateX, {
toValue: 0,
useNativeDriver: true,
}).start();
Animated.spring(translateY, {
toValue: 0,
useNativeDriver: true,
}).start();
}
};
return (
<GestureHandlerRootView style={styles.container}>
<PanGestureHandler
onGestureEvent={onGestureEvent}
onHandlerStateChange={onHandlerStateChange}>
<Animated.View
style={[
styles.box,
{
transform: [{translateX}, {translateY}],
},
]}
/>
</PanGestureHandler>
</GestureHandlerRootView>
);
}
const styles = StyleSheet.create({
container: {
flex: 1,
justifyContent: 'center',
alignItems: 'center',
},
box: {
width: 100,
height: 100,
backgroundColor: 'tomato',
borderRadius: 10,
},
});
```
</details>
and added a breakpoint to check whether we get correct `UIManager` instance:
UIManagerType error (#3466)1 parent a979d1d commit 91e2f71
File tree
1 file changed
+2
-0
lines changed- android/fabric/src/main/java/com/swmansion/gesturehandler
1 file changed
+2
-0
lines changedLines changed: 2 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
5 | 5 | | |
6 | 6 | | |
7 | 7 | | |
| 8 | + | |
8 | 9 | | |
9 | 10 | | |
| 11 | + | |
10 | 12 | | |
11 | 13 | | |
12 | 14 | | |
0 commit comments