mirror of
https://github.com/facebook/react-native.git
synced 2025-11-01 09:14:26 +00:00
refactor ViewGroupManager to use IViewGroupManager
Summary: In this diff I'm refactoring ViewGroupManager to implement IViewGroupManager This will be used by ViewManagers that require to add views but don't depend on ViewGroupmanager changelog: [internal] internal Reviewed By: javache Differential Revision: D41386918 fbshipit-source-id: 427b9689eb3408c2477cf38494d42280b41fd7d8
This commit is contained in:
1 parent
c0a0481656
commit
2f06b26634
3 files changed
+15
-11
No files matched your search
+6
-6
@@ -36,6 +36,7 @@ import com.facebook.react.fabric.mounting.MountingManager.MountItemExecutor;
|
||||
import com.facebook.react.fabric.mounting.mountitems.MountItem;
|
||||
import com.facebook.react.modules.core.ReactChoreographer;
|
||||
import com.facebook.react.touch.JSResponderHandler;
|
||||
import com.facebook.react.uimanager.IViewGroupManager;
|
||||
import com.facebook.react.uimanager.IllegalViewOperationException;
|
||||
import com.facebook.react.uimanager.ReactOverflowViewWithInset;
|
||||
import com.facebook.react.uimanager.ReactRoot;
|
||||
@@ -44,7 +45,6 @@ import com.facebook.react.uimanager.RootView;
|
||||
import com.facebook.react.uimanager.RootViewManager;
|
||||
import com.facebook.react.uimanager.StateWrapper;
|
||||
import com.facebook.react.uimanager.ThemedReactContext;
|
||||
import com.facebook.react.uimanager.ViewGroupManager;
|
||||
import com.facebook.react.uimanager.ViewManager;
|
||||
import com.facebook.react.uimanager.ViewManagerRegistry;
|
||||
import com.facebook.react.uimanager.events.EventCategoryDef;
|
||||
@@ -478,7 +478,7 @@ public class SurfaceMountingManager {
|
||||
logViewHierarchy(parentView, false);
|
||||
}
|
||||
|
||||
ViewGroupManager<ViewGroup> viewGroupManager = getViewGroupManager(parentViewState);
|
||||
IViewGroupManager<ViewGroup> viewGroupManager = getViewGroupManager(parentViewState);
|
||||
|
||||
// Verify that the view we're about to remove has the same tag we expect
|
||||
View view = viewGroupManager.getChildAt(parentView, index);
|
||||
@@ -639,7 +639,7 @@ public class SurfaceMountingManager {
|
||||
logViewHierarchy(parentView, false);
|
||||
}
|
||||
|
||||
ViewGroupManager<ViewGroup> viewGroupManager = getViewGroupManager(parentViewState);
|
||||
IViewGroupManager<ViewGroup> viewGroupManager = getViewGroupManager(parentViewState);
|
||||
|
||||
// Verify that the view we're about to remove has the same tag we expect
|
||||
View view = viewGroupManager.getChildAt(parentView, index);
|
||||
@@ -979,7 +979,7 @@ public class SurfaceMountingManager {
|
||||
}
|
||||
|
||||
ViewState parentViewState = getViewState(parentTag);
|
||||
ViewGroupManager<?> parentViewManager = null;
|
||||
IViewGroupManager<?> parentViewManager = null;
|
||||
if (parentViewState.mViewManager != null) {
|
||||
parentViewManager = parentViewState.mViewManager.getViewGroupManager();
|
||||
}
|
||||
@@ -1257,12 +1257,12 @@ public class SurfaceMountingManager {
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked") // prevents unchecked conversion warn of the <ViewGroup> type
|
||||
private static @NonNull ViewGroupManager<ViewGroup> getViewGroupManager(
|
||||
private static @NonNull IViewGroupManager<ViewGroup> getViewGroupManager(
|
||||
@NonNull ViewState viewState) {
|
||||
if (viewState.mViewManager == null) {
|
||||
throw new IllegalStateException("Unable to find ViewManager for view: " + viewState);
|
||||
}
|
||||
return (ViewGroupManager<ViewGroup>) viewState.mViewManager.getViewGroupManager();
|
||||
return (IViewGroupManager<ViewGroup>) viewState.mViewManager.getViewGroupManager();
|
||||
}
|
||||
|
||||
public void printSurfaceState() {
|
||||
|
||||
@@ -16,7 +16,7 @@ import java.util.WeakHashMap;
|
||||
|
||||
/** Class providing children management API for view managers of classes extending ViewGroup. */
|
||||
public abstract class ViewGroupManager<T extends ViewGroup>
|
||||
extends BaseViewManager<T, LayoutShadowNode> implements IViewManagerWithChildren {
|
||||
extends BaseViewManager<T, LayoutShadowNode> implements IViewGroupManager<T> {
|
||||
|
||||
private static WeakHashMap<View, Integer> mZIndexHash = new WeakHashMap<>();
|
||||
|
||||
@@ -33,6 +33,7 @@ public abstract class ViewGroupManager<T extends ViewGroup>
|
||||
@Override
|
||||
public void updateExtraData(T root, Object extraData) {}
|
||||
|
||||
@Override
|
||||
public void addView(T parent, View child, int index) {
|
||||
parent.addView(child, index);
|
||||
}
|
||||
@@ -60,14 +61,17 @@ public abstract class ViewGroupManager<T extends ViewGroup>
|
||||
return mZIndexHash.get(view);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getChildCount(T parent) {
|
||||
return parent.getChildCount();
|
||||
}
|
||||
|
||||
@Override
|
||||
public View getChildAt(T parent, int index) {
|
||||
return parent.getChildAt(index);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void removeViewAt(T parent, int index) {
|
||||
UiThreadUtil.assertOnUiThread();
|
||||
|
||||
|
||||
@@ -10,10 +10,10 @@ package com.facebook.react.views.view
|
||||
import android.view.View
|
||||
import com.facebook.react.bridge.ReadableArray
|
||||
import com.facebook.react.touch.JSResponderHandler
|
||||
import com.facebook.react.uimanager.IViewGroupManager
|
||||
import com.facebook.react.uimanager.ReactStylesDiffMap
|
||||
import com.facebook.react.uimanager.StateWrapper
|
||||
import com.facebook.react.uimanager.ThemedReactContext
|
||||
import com.facebook.react.uimanager.ViewGroupManager
|
||||
import com.facebook.react.uimanager.ViewManager
|
||||
|
||||
interface ReactViewManagerWrapper {
|
||||
@@ -41,7 +41,7 @@ interface ReactViewManagerWrapper {
|
||||
|
||||
fun getName(): String
|
||||
|
||||
val viewGroupManager: ViewGroupManager<*>
|
||||
val viewGroupManager: IViewGroupManager<*>
|
||||
|
||||
class DefaultViewManager(private val viewManager: ViewManager<View, *>) :
|
||||
ReactViewManagerWrapper {
|
||||
@@ -84,7 +84,7 @@ interface ReactViewManagerWrapper {
|
||||
|
||||
override fun getName(): String = viewManager.name
|
||||
|
||||
override val viewGroupManager: ViewGroupManager<*>
|
||||
get() = viewManager as ViewGroupManager<*>
|
||||
override val viewGroupManager: IViewGroupManager<*>
|
||||
get() = viewManager as IViewGroupManager<*>
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user