Skip to content

Commit

Permalink
Mark ViewGroupManager.getChildAt() as Nullable
Browse files Browse the repository at this point in the history
Summary:
ViewGroup.getChildAt() is nullable, we should make ViewGroupManager.getChildAt() as well.

see https://android.googlesource.com/platform/frameworks/base/+/master/core/java/android/view/ViewGroup.java#6939


changelog: [internal] internal

Differential Revision: D54271529
  • Loading branch information
mdvacca authored and facebook-github-bot committed Feb 28, 2024
1 parent c3b0a8f commit dca8cd1
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
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;

Expand All @@ -19,6 +20,7 @@ public interface IViewGroupManager<T extends View> extends IViewManagerWithChild
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. */
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ public int getChildCount(T parent) {
}

@Override
@Nullable
public View getChildAt(T parent, int index) {
return parent.getChildAt(index);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
package com.facebook.react.views.view;

import android.view.View;
import androidx.annotation.Nullable;
import com.facebook.infer.annotation.Nullsafe;
import com.facebook.react.bridge.UiThreadUtil;
import com.facebook.react.uimanager.ViewGroupManager;
Expand Down Expand Up @@ -52,6 +53,7 @@ public int getChildCount(T parent) {
}

@Override
@Nullable
public View getChildAt(T parent, int index) {
boolean removeClippedSubviews = parent.getRemoveClippedSubviews();
if (removeClippedSubviews) {
Expand All @@ -68,10 +70,12 @@ public void removeViewAt(T parent, int index) {
boolean removeClippedSubviews = parent.getRemoveClippedSubviews();
if (removeClippedSubviews) {
View child = getChildAt(parent, index);
if (child.getParent() != null) {
parent.removeView(child);
if (child != null) {
if (child.getParent() != null) {
parent.removeView(child);
}
parent.removeViewWithSubviewClippingEnabled(child);
}
parent.removeViewWithSubviewClippingEnabled(child);
} else {
parent.removeViewAt(index);
}
Expand Down

0 comments on commit dca8cd1

Please sign in to comment.