@Test public void belongTo_positive1() { FrameLayout container = new FrameLayout(context); View view = new View(context); container.addView(view); boolean result = ViewHelper.belongTo(container, view); assertTrue(result); }
public static boolean belongTo(@NonNull ViewGroup parent, @NonNull View child) { ViewParent viewParent = child.getParent(); if (viewParent instanceof ViewGroup) { ViewGroup viewGroup = (ViewGroup) viewParent; return viewGroup.equals(parent) || belongTo(parent, viewGroup); } else { return false; } }
ViewHelper { public static boolean belongTo(@NonNull ViewGroup parent, @NonNull View child) { ViewParent viewParent = child.getParent(); if (viewParent instanceof ViewGroup) { ViewGroup viewGroup = (ViewGroup) viewParent; return viewGroup.equals(parent) || belongTo(parent, viewGroup); } else { return false; } } }
ViewHelper { public static boolean belongTo(@NonNull ViewGroup parent, @NonNull View child) { ViewParent viewParent = child.getParent(); if (viewParent instanceof ViewGroup) { ViewGroup viewGroup = (ViewGroup) viewParent; return viewGroup.equals(parent) || belongTo(parent, viewGroup); } else { return false; } }  }
ViewHelper { public static boolean belongTo(@NonNull ViewGroup parent, @NonNull View child) { ViewParent viewParent = child.getParent(); if (viewParent instanceof ViewGroup) { ViewGroup viewGroup = (ViewGroup) viewParent; return viewGroup.equals(parent) || belongTo(parent, viewGroup); } else { return false; } }  static boolean belongTo(@NonNull ViewGroup parent, @NonNull View child); }
ViewHelper { public static boolean belongTo(@NonNull ViewGroup parent, @NonNull View child) { ViewParent viewParent = child.getParent(); if (viewParent instanceof ViewGroup) { ViewGroup viewGroup = (ViewGroup) viewParent; return viewGroup.equals(parent) || belongTo(parent, viewGroup); } else { return false; } }  static boolean belongTo(@NonNull ViewGroup parent, @NonNull View child);  }