mirror of
https://github.com/facebook/react-native.git
synced 2025-11-01 09:14:26 +00:00
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
This commit is contained in:
committed by
Facebook GitHub Bot
parent
4c47c1651b
commit
b32f447f89
-42
@@ -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<T extends View> 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);
|
||||
}
|
||||
+35
@@ -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<T : View> : 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
|
||||
}
|
||||
Reference in New Issue
Block a user