Example usage for android.view ViewGroup getChildAt

List of usage examples for android.view ViewGroup getChildAt

Introduction

In this page you can find the example usage for android.view ViewGroup getChildAt.

Prototype

public View getChildAt(int index) 

Source Link

Document

Returns the view at the specified position in the group.

Usage

From source file:io.github.prefanatic.cleantap.util.AnimUtils.java

public static void showChildren(ViewGroup group) {
    FastOutLinearInInterpolator interpolator = new FastOutLinearInInterpolator();

    for (int i = 0; i < group.getChildCount(); i++) {
        View view = group.getChildAt(i);

        view.setTranslationY(view.getHeight() / 3);
        view.setAlpha(0f);/*from  w w  w .j  a  va 2s . c o  m*/
        view.animate().alpha(1f).translationY(0f).setStartDelay(0L).setDuration(150L)
                //.setInterpolator(interpolator)
                .start();

    }
}

From source file:android.support.v7.testutils.TestUtilsMatchers.java

/**
 * Returns a matcher that matches {@link View}s based on the given child type.
 *
 * @param childMatcher the type of the child to match on
 *///from  w ww.j  a v  a  2 s .c  o  m
public static Matcher<ViewGroup> hasChild(final Matcher<View> childMatcher) {
    return new TypeSafeMatcher<ViewGroup>() {
        @Override
        public void describeTo(Description description) {
            description.appendText("has child: ");
            childMatcher.describeTo(description);
        }

        @Override
        public boolean matchesSafely(ViewGroup view) {
            final int childCount = view.getChildCount();
            for (int i = 0; i < childCount; i++) {
                if (childMatcher.matches(view.getChildAt(i))) {
                    return true;
                }
            }
            return false;
        }
    };
}

From source file:com.github.shareme.gwsmaterialuikit.library.advancerv.utils.CustomRecyclerViewUtils.java

private static View findChildViewUnderWithoutTranslation(@NonNull ViewGroup parent, float x, float y) {
    final int count = parent.getChildCount();
    for (int i = count - 1; i >= 0; i--) {
        final View child = parent.getChildAt(i);
        if (x >= child.getLeft() && x <= child.getRight() && y >= child.getTop() && y <= child.getBottom()) {
            return child;
        }/*from  w  ww . java2 s. co m*/
    }
    return null;
}

From source file:com.google.android.apps.common.testing.accessibility.framework.ViewAccessibilityUtils.java

/**
 * Determines if the supplied {@link View} has child view(s) which are not independently
 * accessibility focusable and also have a spoken description. Put another way, this method
 * determines if {@code view} has at least one child which should be included in {@code view}'s
 * spoken description if {@code view} were to be accessibility focused.
 *
 * @param view The {@link View} to evaluate
 * @return {@code true} if {@code view} has non-actionable speaking children within its subtree
 *//*from  w ww. ja  va 2s  .c  o m*/
private static boolean hasNonActionableSpeakingChildren(View view) {
    if ((view == null) || !(view instanceof ViewGroup)) {
        return false;
    }

    ViewGroup group = (ViewGroup) view;
    for (int i = 0; i < group.getChildCount(); ++i) {
        View child = group.getChildAt(i);
        if ((child == null) || (child.getVisibility() != View.VISIBLE) || isAccessibilityFocusable(child)) {
            continue;
        }

        if (isImportantForAccessibility(child) && isSpeakingView(child)) {
            return true;
        }
    }

    return false;
}

From source file:com.google.android.apps.common.testing.accessibility.framework.ViewAccessibilityUtils.java

private static View lookForLabelForViewInViewAndChildren(View view, View childToSkip, int idToFind) {
    if (view.getLabelFor() == idToFind) {
        return view;
    }//w ww  .  j ava  2  s  .  co m
    if (!(view instanceof ViewGroup)) {
        return null;
    }
    ViewGroup viewGroup = (ViewGroup) view;
    for (int i = 0; i < viewGroup.getChildCount(); ++i) {
        View child = viewGroup.getChildAt(i);
        if (!child.equals(childToSkip)) {
            View labelingView = lookForLabelForViewInViewAndChildren(child, null, idToFind);
            if (labelingView != null) {
                return labelingView;
            }
        }
    }
    return null;
}

From source file:Main.java

/**
 * Borrowed from android.support.design.widget.AppBarLayout
 *///from w w  w .j  a  v a2  s.c  om
public static int getMinimumHeightForVisibleOverlappingContent(ViewGroup appBarLayout) {
    final int topInset = getTopInset(appBarLayout);
    final int minHeight = ViewCompat.getMinimumHeight(appBarLayout);
    if (minHeight != 0) {
        // If this layout has a min height, use it (doubled)
        return (minHeight * 2) + topInset;
    }

    // Otherwise, we'll use twice the min height of our last child
    final int childCount = appBarLayout.getChildCount();
    return childCount >= 1
            ? (ViewCompat.getMinimumHeight(appBarLayout.getChildAt(childCount - 1)) * 2) + topInset
            : 0;
}

From source file:com.google.android.apps.common.testing.accessibility.framework.ViewAccessibilityUtils.java

/**
 * Add all children in the view tree rooted at rootView to a set
 *
 * @param rootView The root of the view tree desired
 * @param theSet The set to add views to
 *//*from   w  ww  . j  a  v  a 2  s  . c  om*/
private static void addAllChildrenToSet(View rootView, Set<View> theSet) {
    if (!(rootView instanceof ViewGroup)) {
        return;
    }

    ViewGroup rootViewGroup = (ViewGroup) rootView;
    for (int i = 0; i < rootViewGroup.getChildCount(); ++i) {
        View nextView = rootViewGroup.getChildAt(i);
        theSet.add(nextView);
        addAllChildrenToSet(nextView, theSet);
    }
}

From source file:dev.drsoran.moloko.util.UIUtils.java

public final static int getTaggedViewPos(ViewGroup container, String tag) {
    int pos = -1;

    for (int i = 0, cnt = container.getChildCount(); i < cnt && pos == -1; ++i) {
        if (tag.equals(container.getChildAt(i).getTag()))
            pos = i;//from   w ww  .j av a  2s  . com
    }

    return pos;
}

From source file:io.selendroid.server.model.internal.AbstractNativeElementContext.java

/** visible for testing */
protected static List<AndroidElement> searchViews(AbstractNativeElementContext context, List<View> roots,
        Predicate predicate, boolean findJustOne) {
    List<AndroidElement> elements = new ArrayList<AndroidElement>();
    if (roots == null || roots.isEmpty()) {
        return elements;
    }/*from  w ww .ja  va2s.c o  m*/
    ArrayDeque<View> queue = new ArrayDeque<View>();

    for (View root : roots) {
        queue.add(root);
        while (!queue.isEmpty()) {
            View view = queue.pop();
            if (predicate.apply(view)) {
                elements.add(context.newAndroidElement(view));
                if (findJustOne) {
                    break;
                }
            }
            if (view instanceof ViewGroup) {
                ViewGroup group = (ViewGroup) view;
                int childrenCount = group.getChildCount();
                for (int index = 0; index < childrenCount; index++) {
                    queue.add(group.getChildAt(index));
                }
            }
        }
    }
    return elements;
}

From source file:dev.drsoran.moloko.util.UIUtils.java

public final static void removeTaggedViews(ViewGroup container, String tag) {
    List<View> views = null;

    for (int i = 0, cnt = container.getChildCount(); i < cnt; ++i) {
        final View v = container.getChildAt(i);
        if (v != null && tag.equals(v.getTag())) {
            if (views == null)
                views = new LinkedList<View>();

            views.add(v);//from w w  w . ja v  a  2s. co m
        }
    }

    if (views != null)
        for (View view : views)
            container.removeView(view);
}