/** * Looks at the parent-chain of the view and if it finds a custom view, or a CalendarView, within * the given distance then it returns true. A ListView within a CalendarView should not be * assigned a custom list view type because it sets its own and then attempts to cast the layout * to its own type which would fail if the normal default list item binding is used. */ private boolean isWithinIllegalParent(Object viewObject, int depth) { String fqcn = viewObject.getClass().getName(); if (fqcn.endsWith(CALENDAR_VIEW) || !fqcn.startsWith(ANDROID_PKG_PREFIX)) { return true; } if (depth > 0) { Result result = mLayoutLib.getViewParent(viewObject); if (result.isSuccess()) { Object parent = result.getData(); if (parent != null) { return isWithinIllegalParent(parent, depth - 1); } } } return false; }