From b32f447f89f2af4894aa9a41335c81fe1be9cadf Mon Sep 17 00:00:00 2001 From: Andrew Datsenko Date: Mon, 29 Jul 2024 06:27:24 -0700 Subject: [PATCH] xplat/js/react-native-github/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/uimanager/IViewGroupManager.java (#45730) Summary: Pull Request resolved: https://github.com/facebook/react-native/pull/45730 Changelog: [Internal] Reviewed By: rshest Differential Revision: D60233485 fbshipit-source-id: 9910b5c5c66a72d2698233b6be0f509f14047ff0 --- .../react/uimanager/IViewGroupManager.java | 42 ------------------- .../react/uimanager/IViewGroupManager.kt | 35 ++++++++++++++++ 2 files changed, 35 insertions(+), 42 deletions(-) delete mode 100644 packages/react-native/ReactAndroid/src/main/java/com/facebook/react/uimanager/IViewGroupManager.java create mode 100644 packages/react-native/ReactAndroid/src/main/java/com/facebook/react/uimanager/IViewGroupManager.kt diff --git a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/uimanager/IViewGroupManager.java b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/uimanager/IViewGroupManager.java deleted file mode 100644 index ea3d91fb3ea..00000000000 --- a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/uimanager/IViewGroupManager.java +++ /dev/null @@ -1,42 +0,0 @@ -/* - * Copyright (c) Meta Platforms, Inc. and affiliates. - * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. - */ - -package com.facebook.react.uimanager; - -import android.view.View; -import androidx.annotation.Nullable; -import com.facebook.infer.annotation.Nullsafe; -import com.facebook.react.bridge.UiThreadUtil; - -/** Interface providing children management API for view managers of classes extending ViewGroup. */ -@Nullsafe(Nullsafe.Mode.LOCAL) -public interface IViewGroupManager extends IViewManagerWithChildren { - - /** Adds a child view into the parent at the index specified as a parameter */ - void addView(T parent, View child, int index); - - /** - * @return child of the parent view at the index specified as a parameter. - */ - @Nullable - View getChildAt(T parent, int index); - - /** Removes View from the parent View at the index specified as a parameter. */ - void removeViewAt(T parent, int index); - - /** Remove all child views from the parent View. */ - default void removeAllViews(T parent) { - UiThreadUtil.assertOnUiThread(); - - for (int i = getChildCount(parent) - 1; i >= 0; i--) { - removeViewAt(parent, i); - } - } - - /** Return the amount of children contained by the view specified as a parameter. */ - int getChildCount(T parent); -} diff --git a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/uimanager/IViewGroupManager.kt b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/uimanager/IViewGroupManager.kt new file mode 100644 index 00000000000..ef45524c689 --- /dev/null +++ b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/uimanager/IViewGroupManager.kt @@ -0,0 +1,35 @@ +/* + * Copyright (c) Meta Platforms, Inc. and affiliates. + * + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. + */ + +package com.facebook.react.uimanager + +import android.view.View +import com.facebook.react.bridge.UiThreadUtil + +/** Interface providing children management API for view managers of classes extending ViewGroup. */ +public interface IViewGroupManager : IViewManagerWithChildren { + + /** Adds a child view into the parent at the index specified as a parameter */ + public fun addView(parent: T, child: View, index: Int) + + /** @return child of the parent view at the index specified as a parameter. */ + public fun getChildAt(parent: T, index: Int): View? + + /** Removes View from the parent View at the index specified as a parameter. */ + public fun removeViewAt(parent: T, index: Int) + + /** Remove all child views from the parent View. */ + public fun removeAllViews(parent: T) { + UiThreadUtil.assertOnUiThread() + for (i in getChildCount(parent) - 1 downTo 0) { + removeViewAt(parent, i) + } + } + + /** Return the amount of children contained by the view specified as a parameter. */ + public fun getChildCount(parent: T): Int +}