Skip to content

Commit 9dd6972

Browse files
cortinicofacebook-github-bot
authored andcommitted
Fix broken Fabric Interop example (facebook#40942)
Summary: Pull Request resolved: facebook#40942 The Fabric Interop example for Android is broken. This is due to the Kotlin conversion which moved the `Color.colorToHSV(color, hsv)` statement *after* the HSV array is read so the array is always [0,0,0]. I'm fixing it here. Changelog: [Internal] [Changed] - Fix broken Fabric Interop example Reviewed By: cipolleschi Differential Revision: D50264766 fbshipit-source-id: 31445e36ae9279f86f4becad9557bda3c932655c
1 parent 09b8aad commit 9dd6972

File tree

1 file changed

+3
-3
lines changed
  • packages/rn-tester/android/app/src/main/java/com/facebook/react/uiapp/component

1 file changed

+3
-3
lines changed

packages/rn-tester/android/app/src/main/java/com/facebook/react/uiapp/component/MyNativeView.kt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ import com.facebook.react.uimanager.events.RCTEventEmitter
2222
class MyNativeView(context: ThemedReactContext) : View(context) {
2323
private var currentColor = 0
2424
private var background: GradientDrawable = GradientDrawable()
25-
private var reactContext: ReactContext = context.getReactApplicationContext()
25+
private var reactContext: ReactContext = context.reactApplicationContext
2626

2727
override fun setBackgroundColor(color: Int) {
2828
if (color != currentColor) {
@@ -34,13 +34,14 @@ class MyNativeView(context: ThemedReactContext) : View(context) {
3434
}
3535

3636
fun setCornerRadius(cornerRadius: Float) {
37-
background.setCornerRadius(cornerRadius)
37+
background.cornerRadius = cornerRadius
3838
setBackground(background)
3939
}
4040

4141
private fun emitNativeEvent(color: Int) {
4242
val event = Arguments.createMap()
4343
val hsv = FloatArray(3)
44+
Color.colorToHSV(color, hsv)
4445
val backgroundColor =
4546
Arguments.createMap().apply {
4647
putDouble("hue", hsv[0].toDouble())
@@ -49,7 +50,6 @@ class MyNativeView(context: ThemedReactContext) : View(context) {
4950
putDouble("alpha", Color.alpha(color).toDouble())
5051
}
5152

52-
Color.colorToHSV(color, hsv)
5353
event.putMap("backgroundColor", backgroundColor)
5454

5555
reactContext.getJSModule(RCTEventEmitter::class.java).receiveEvent(id, "onColorChanged", event)

0 commit comments

Comments
 (0)