From 287e20033207df5e59d199a347b7ae2b4cd7a59e Mon Sep 17 00:00:00 2001 From: Nicola Corti Date: Tue, 5 Nov 2024 04:11:48 -0800 Subject: [PATCH] Stable API - Convert to Kotlin and make internal `NotThreadSafeViewHierarchyUpdateDebugListener` (#47371) Summary: Pull Request resolved: https://github.com/facebook/react-native/pull/47371 This interface should have not been exposed in the first place. I'm converting it to Kotlin + making it `internal`. I found no meaningful usage in OSS so I expect no breakages. Changelog: [Android] [Breaking] - Stable API - Convert to Kotlin and make internal `NotThreadSafeViewHierarchyUpdateDebugListener` Reviewed By: javache Differential Revision: D65420912 fbshipit-source-id: 5afdb013f588a5698b4e7467a7f1096c24d1733e --- .../ReactAndroid/api/ReactAndroid.api | 5 ----- .../react/uimanager/UIImplementation.java | 2 ++ .../react/uimanager/UIManagerModule.java | 2 ++ .../react/uimanager/UIViewOperationQueue.java | 2 ++ ...eadSafeViewHierarchyUpdateDebugListener.kt} | 18 +++++++----------- 5 files changed, 13 insertions(+), 16 deletions(-) rename packages/react-native/ReactAndroid/src/main/java/com/facebook/react/uimanager/debug/{NotThreadSafeViewHierarchyUpdateDebugListener.java => NotThreadSafeViewHierarchyUpdateDebugListener.kt} (57%) diff --git a/packages/react-native/ReactAndroid/api/ReactAndroid.api b/packages/react-native/ReactAndroid/api/ReactAndroid.api index b76548b510b..b238f03c159 100644 --- a/packages/react-native/ReactAndroid/api/ReactAndroid.api +++ b/packages/react-native/ReactAndroid/api/ReactAndroid.api @@ -5658,11 +5658,6 @@ public final class com/facebook/react/uimanager/common/ViewUtil { public static final fun isRootTag (I)Z } -public abstract interface class com/facebook/react/uimanager/debug/NotThreadSafeViewHierarchyUpdateDebugListener { - public abstract fun onViewHierarchyUpdateEnqueued ()V - public abstract fun onViewHierarchyUpdateFinished ()V -} - public abstract interface class com/facebook/react/uimanager/events/BatchEventDispatchedListener { public abstract fun onBatchEventDispatched ()V } diff --git a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/uimanager/UIImplementation.java b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/uimanager/UIImplementation.java index 401e8b26a30..afa1d3a968d 100644 --- a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/uimanager/UIImplementation.java +++ b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/uimanager/UIImplementation.java @@ -774,6 +774,8 @@ public class UIImplementation { mViewManagers.invalidate(); } + // NOTE: When converted to Kotlin this method should be `internal` due to + // visibility restriction for `NotThreadSafeViewHierarchyUpdateDebugListener` public void setViewHierarchyUpdateDebugListener( @Nullable NotThreadSafeViewHierarchyUpdateDebugListener listener) { mOperationsQueue.setViewHierarchyUpdateDebugListener(listener); diff --git a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/uimanager/UIManagerModule.java b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/uimanager/UIManagerModule.java index 9ecad6f5d88..7a3cfc55ae6 100644 --- a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/uimanager/UIManagerModule.java +++ b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/uimanager/UIManagerModule.java @@ -687,6 +687,8 @@ public class UIManagerModule extends ReactContextBaseJavaModule } } + // NOTE: When converted to Kotlin this method should be `internal` due to + // visibility restriction for `NotThreadSafeViewHierarchyUpdateDebugListener` public void setViewHierarchyUpdateDebugListener( @Nullable NotThreadSafeViewHierarchyUpdateDebugListener listener) { mUIImplementation.setViewHierarchyUpdateDebugListener(listener); diff --git a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/uimanager/UIViewOperationQueue.java b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/uimanager/UIViewOperationQueue.java index 383d02d0a70..3e284122ca6 100644 --- a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/uimanager/UIViewOperationQueue.java +++ b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/uimanager/UIViewOperationQueue.java @@ -609,6 +609,8 @@ public class UIViewOperationQueue { return mNativeViewHierarchyManager; } + // NOTE: When converted to Kotlin this method should be `internal` due to + // visibility restriction for `NotThreadSafeViewHierarchyUpdateDebugListener` public void setViewHierarchyUpdateDebugListener( @Nullable NotThreadSafeViewHierarchyUpdateDebugListener listener) { mViewHierarchyUpdateDebugListener = listener; diff --git a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/uimanager/debug/NotThreadSafeViewHierarchyUpdateDebugListener.java b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/uimanager/debug/NotThreadSafeViewHierarchyUpdateDebugListener.kt similarity index 57% rename from packages/react-native/ReactAndroid/src/main/java/com/facebook/react/uimanager/debug/NotThreadSafeViewHierarchyUpdateDebugListener.java rename to packages/react-native/ReactAndroid/src/main/java/com/facebook/react/uimanager/debug/NotThreadSafeViewHierarchyUpdateDebugListener.kt index 9a6b65eba79..9027ed465e1 100644 --- a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/uimanager/debug/NotThreadSafeViewHierarchyUpdateDebugListener.java +++ b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/uimanager/debug/NotThreadSafeViewHierarchyUpdateDebugListener.kt @@ -5,26 +5,22 @@ * LICENSE file in the root directory of this source tree. */ -package com.facebook.react.uimanager.debug; +package com.facebook.react.uimanager.debug -import com.facebook.react.common.annotations.DeprecatedInNewArchitecture; -import com.facebook.react.uimanager.UIManagerModule; +import com.facebook.react.common.annotations.DeprecatedInNewArchitecture /** * A listener that is notified about view hierarchy update events. This listener should only be used * for debug purposes and should not affect application state. * - *

NB: while onViewHierarchyUpdateFinished will always be called from the UI thread, there are no + * NB: while [onViewHierarchyUpdateFinished] will always be called from the UI thread, there are no * guarantees what thread onViewHierarchyUpdateEnqueued is called on. */ @DeprecatedInNewArchitecture -public interface NotThreadSafeViewHierarchyUpdateDebugListener { - - /** - * Called when {@link UIManagerModule} enqueues a UI batch to be dispatched to the main thread. - */ - void onViewHierarchyUpdateEnqueued(); +internal interface NotThreadSafeViewHierarchyUpdateDebugListener { + /** Called when `UIManagerModule` enqueues a UI batch to be dispatched to the main thread. */ + fun onViewHierarchyUpdateEnqueued() /** Called from the main thread after a UI batch has been applied to all root views. */ - void onViewHierarchyUpdateFinished(); + fun onViewHierarchyUpdateFinished() }