Skip to content

Commit

Permalink
Add android log when trying to add a view into a non viewGroup
Browse files Browse the repository at this point in the history
Summary:
Easy diff to add extra logging when Fabric tries to add a view inside a view that is not a ViewGroup

changelog: [internal]

Reviewed By: JoshuaGross

Differential Revision: D19737506

fbshipit-source-id: ecb858820de7befc385e725c45b537359e39c0e7
  • Loading branch information
mdvacca authored and facebook-github-bot committed Feb 5, 2020
1 parent 928fe12 commit 8dcab66
Showing 1 changed file with 12 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.annotation.UiThread;
import com.facebook.common.logging.FLog;
import com.facebook.infer.annotation.Assertions;
import com.facebook.infer.annotation.ThreadConfined;
import com.facebook.react.bridge.ReactNoCrashSoftException;
Expand Down Expand Up @@ -113,6 +114,17 @@ private void dropView(@NonNull View view) {
public void addViewAt(int parentTag, int tag, int index) {
UiThreadUtil.assertOnUiThread();
ViewState parentViewState = getViewState(parentTag);
if (!(parentViewState.mView instanceof ViewGroup)) {
String message =
"Unable to add a view into a view that is not a ViewGroup. ParentTag: "
+ parentTag
+ " - Tag: "
+ tag
+ " - Index: "
+ index;
FLog.e(TAG, message);
throw new IllegalStateException(message);
}
final ViewGroup parentView = (ViewGroup) parentViewState.mView;
ViewState viewState = getViewState(tag);
final View view = viewState.mView;
Expand Down

0 comments on commit 8dcab66

Please sign in to comment.