/** * Remove all child views. */ private void removeCardViews() { for (int i = 0; i < getChildCount(); i++) { removeViewAt(i); i--; } }
/** * Sorts children in reverse order for drawing. */ private void sortChildDrawingOrder() { if (drawingOrderedChildren == null) { drawingOrderedChildren = new ArrayList<>(); } else { drawingOrderedChildren.clear(); } final int childCount = getChildCount(); for (int i = 0; i < childCount; i++) { final View child = getChildAt(i); drawingOrderedChildren.add(child); } Collections.sort(drawingOrderedChildren, VIEW_COMPARATOR); }
/** * Enable or disable hardware layers for drawing in children. * * @param enable enable */ private void enableLayers(boolean enable) { final int childCount = getChildCount(); for (int i = 0; i < childCount; i++) { final int layerType = enable ? ViewCompat.LAYER_TYPE_HARDWARE : ViewCompat.LAYER_TYPE_NONE; ViewCompat.setLayerType(getChildAt(i), layerType, null); } }
/** * We only want the current page that is being shown to be touchable. */ @Override public void addTouchables(@NonNull ArrayList<View> views) { // Note that we don't call super.addTouchables(). // This is okay because a Pager is itself not touchable. for (int i = 0; i < getChildCount(); i++) { final View child = getChildAt(i); if (child.getVisibility() == VISIBLE) { ItemInfo ii = infoForChild(child); if (ii != null && ii.position == currentItem) { child.addTouchables(views); } } } }
int increment; int end; int count = getChildCount(); if ((direction & FOCUS_FORWARD) != 0) { index = 0;
/** * This method will be invoked when the current page is scrolled, either as part * of a programmatically initiated smooth scroll or a user initiated touch scroll. */ protected void onPageScrolled() { final int scrollX = getScrollX(); final int childCount = getChildCount(); for (int i = 0; i < childCount; i++) { final View child = getChildAt(i); final float transformPos = (float) (child.getLeft() - scrollX) / getClientWidth(); transformPage(child, transformPos); } }
@Override protected void onLayout(boolean changed, int l, int t, int r, int b) { final int count = getChildCount(); int width = r - l; int height = b - t;
final int childCount = getChildCount(); for (int i = 0; i < childCount; i++) { final View child = getChildAt(i);
if (getChildCount() == 0) {
for (int i = 0; i < getChildCount(); i++) { final View child = getChildAt(i); if (child.getVisibility() == VISIBLE) {
/** * Check if child needs focus. * * @param focusDirection focusDirection */ private void checkFocus(int focusDirection) { if (hasFocus()) { View currentFocused = findFocus(); ItemInfo ii = currentFocused != null ? infoForAnyChild(currentFocused) : null; if (ii == null || ii.position != currentItem) { for (int i = 0; i < getChildCount(); i++) { View child = getChildAt(i); ii = infoForChild(child); if (ii != null && ii.position == currentItem) { if (child.requestFocus(focusDirection)) { break; } } } } } }
@Override protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) { // For simple implementation, our internal size is always 0. // We depend on the container to specify the layout size of // our view. We can't really know what it is since we will be // adding and removing different arbitrary views and do not // want the layout to change as this happens. setMeasuredDimension(getDefaultSize(0, widthMeasureSpec), getDefaultSize(0, heightMeasureSpec)); final int measuredWidth = getMeasuredWidth(); // Children are just made to fill our space. int childWidthSize = measuredWidth - getPaddingLeft() - getPaddingRight(); int childHeightSize = getMeasuredHeight() - getPaddingTop() - getPaddingBottom(); int childWidthMeasureSpec = MeasureSpec.makeMeasureSpec(childWidthSize, MeasureSpec.EXACTLY); int childHeightMeasureSpec = MeasureSpec.makeMeasureSpec(childHeightSize, MeasureSpec.EXACTLY); // Make sure we have created all fragments that we need to have shown. inLayout = true; populate(); inLayout = false; // Page views. final int size = getChildCount(); for (int i = 0; i < size; ++i) { final View child = getChildAt(i); if (child.getVisibility() != GONE) { child.measure(childWidthMeasureSpec, childHeightMeasureSpec); } } }
final int childCount = getChildCount(); for (int i = 0; i < childCount; i++) { final View child = getChildAt(i);